I have created a site using php programming language...
To make my site dynamic , I have created some pages like header.php, mainmenu.php, etc. and have embeded each to their respected location using
<?php
echo include("header.php");
?>
all is working fine but on browsing my site ... it has '1' at every place PHP file is included...
Is there any way to remove thisss.....
Please help...
You can get it on
www.anujweb.co.cc/phptest
You can also get it on the image uploaded marked with red circle..
16 Replies - 703 Views - Last Post: 05 April 2012 - 05:42 AM
Replies To: Embedding PHP page in other php page
#2
Re: Embedding PHP page in other php page
Posted 31 March 2012 - 07:55 PM
Html text from site :
We can't view php source, so you're going to have to hunt this down in the code. I would suggest there is a statement echo "1"; somewhere in the code.
<link href='styles.css' rel='stylesheet' type='text/css' media='screen' /></body>
</html>
1 </head>
<body onload="getLocation()">
We can't view php source, so you're going to have to hunt this down in the code. I would suggest there is a statement echo "1"; somewhere in the code.
#3
Re: Embedding PHP page in other php page
Posted 31 March 2012 - 08:24 PM
No, there is nothing like echo"1" in any php page...
Example of main index page...
Example of Header.php
Example of main index page...
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Welcome</title>
<meta name="keywords" content="free" />
<meta name="description" content="free" />
<?php
echo include("style.php"); // to include style sheet from style.php
?>
</head>
<body onload="getLocation()">
<div id="content">
<!-- header begins -->
<div id="headertop">
<div id="menu">
<?php
echo include("mainmenu.php"); // to include main menu from meinmenu.php
?>
</div>
<div id="logo">
<?php
echo include("logo.php"); // to include website logo
?>
</div>
</div><div style="clear:both;"></div>
<!---- Header begins here --->
<?php
include("header.php"); // to include header page
?>
<!-- header ends -->
<!-- content begins -->
<div id="main">
<div id="dropdown">
<center>
<?php include("dropdown.php");
?>
</center>
</div>
<div id="leftcon">
<h2>Welcome to AnujWeb</h2>
<p>You are most welcome to AnujWeb .
Enjoy your journy to this site and have fun and make your life spicy.
You can Bookmark The Site or Set as Homepage for easy visit.
Have any problem please use Contact Me page and give your comments.
Thanks for your visit...</p>
Example of Header.php
<!DOCTYPE HTML>
<html>
<head>
<title>Header</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="styles.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<?php
echo "
<div id='header'>
<div id='logform'>
<div id='log_top'></div>
<div id='log'>
<h3>User Login</h3>
<!-- <form id='form1' method='post' action='#'>
<fieldset>
<label for='text1'>Username</label><br />
<input id='text1' type='text' name='text1' value='' /><br />
<label for='text2'>Password</label><br />
<input id='text2' type='password' name='text2' value='' /><br />
<input type='submit' id='login-submit' value='' />
</fieldset>
</form>
<img src='images/log_ls.png' title='' alt='' style='padding-right: 5px; padding-bottom: 2px;'/><a href='register.php'>Create new account</a><br />
<img src='images/log_ls.png' title='' alt='' style='padding-right: 5px; padding-bottom: 2px;'/><a href='#'>Request new password</a>
-->
<fb:login-button
registration-url='https://www.anujweb.co.cc/phptest/register.php' />
</div>
<div id='log_bot'></div>
<div id='search'>
<form method='get' action=''>
<fieldset>
<input type='text' name='s' id='search-text' size='15' />
<input type='submit' id='search-submit' value='' />
</fieldset>
</form>
</div></div>
</div>";
?>
<!-- end #search -->
</body>
</html>
#4
Re: Embedding PHP page in other php page
Posted 31 March 2012 - 08:32 PM
Why are you creating multiple body & html tags within a single page? That's going to make troubleshooting this a little more challenging.
Look here:
Example error :
Php code :
Start with "free" & that's the last line in php (even though it's html) you call style.php, & then end head. Scroll to the bottom of the output & find the end head segment. The 1 is output from style.php.
Look here:
Example error :
<meta name="description" content="free" />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Style</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<link href='styles.css' rel='stylesheet' type='text/css' media='screen' /></body>
</html>
1 </head>
Php code :
<meta name="description" content="free" />
<?php
echo include("style.php"); // to include style sheet from style.php
?>
</head>
<body onload="getLocation()">
Start with "free" & that's the last line in php (even though it's html) you call style.php, & then end head. Scroll to the bottom of the output & find the end head segment. The 1 is output from style.php.
#5
Re: Embedding PHP page in other php page
Posted 31 March 2012 - 08:37 PM
Mixing languages that don't even run on the same computer is asking for trouble.
What do you think this will do?
What do you think this will do?
echo include("style.php");
#6
Re: Embedding PHP page in other php page
Posted 31 March 2012 - 10:09 PM
You mean IF I remove all html tags and body tags from php pages included will do this
#7
Re: Embedding PHP page in other php page
Posted 31 March 2012 - 10:42 PM
Quote
No, there is nothing like echo"1" in any php page...
Note that unless your included PHP files actually return something, don't use echo when you include them. If you do, the echo statement will print 1. (See the manual for full details on how that works!)
// File: include.php <h1>Some HTML, or something</h1> // File: index.php echo include "include.php" // Output: <h1>Some HTML, or something</h1>1
The 1 at the end there goes away if you remove the echo from the include.
#8
Re: Embedding PHP page in other php page
Posted 01 April 2012 - 07:11 AM
anujsharma002, on 01 April 2012 - 01:09 AM, said:
You mean IF I remove all html tags and body tags from php pages included will do this
What I mean is that removing html from php scripts (they aren't pages: pages are sent to browsers) then the remaining PHP will be easier to read. Code that is easy to read is easy to debug. You can think of every problem you'll ever have debugging any programming language as being a result of your inability to read the code, so making it easier to read should always be your first priority.
#9
Re: Embedding PHP page in other php page
Posted 01 April 2012 - 07:55 AM
Like Atli said, you shouldn't echo include statements unless you are trying to determine if the include was successful. If you need to use PHP together with your HTML, it can be done, by doing this: <div><?php include('header.php') ?></div>.
On an unrelated note, you should be aware that upon opening this thread, ESET Smart Security panicked at the sight of www.anujweb.co.cc/phptest. Infact, when I went to your site I was given this message:
If that's your site, you might want to have something done about it. Getting on these kinds of lists isn't very good for business
- Cbeppe
On an unrelated note, you should be aware that upon opening this thread, ESET Smart Security panicked at the sight of www.anujweb.co.cc/phptest. Infact, when I went to your site I was given this message:
Quote
Access to the web page was blocked by ESET Smart Security. The web page is on the list of websites with potentially dangerous contents.
If that's your site, you might want to have something done about it. Getting on these kinds of lists isn't very good for business
- Cbeppe
#10
Re: Embedding PHP page in other php page
Posted 04 April 2012 - 09:05 AM
tHANKS Atli...
This worked good...
Now '1' has been removed by removing echo...
This worked good...
Now '1' has been removed by removing echo...
#11
Re: Embedding PHP page in other php page
Posted 04 April 2012 - 09:15 AM
Dear Cbeppe,
I'm beginner to web designing....
My webpages don't have any thing miscllanious other than simple codes...
I don't know why your ESET Smart Security program is showing such message...
I'm beginner to web designing....
My webpages don't have any thing miscllanious other than simple codes...
I don't know why your ESET Smart Security program is showing such message...
#12
Re: Embedding PHP page in other php page
Posted 04 April 2012 - 09:30 AM
My guess would be that you use mysql_* functions and don't scrub user supplied data. Start reading up on prepared statements.
#13
Re: Embedding PHP page in other php page
Posted 04 April 2012 - 10:54 AM
Sorry !!! CTphpnwb but I don't use mysql_* function.
#14
Re: Embedding PHP page in other php page
Posted 04 April 2012 - 11:03 AM
If you do something like:
then you do.
mysql_query("SELECT * FROM some_table");
then you do.
#15
Re: Embedding PHP page in other php page
Posted 04 April 2012 - 08:02 PM
Sorry !!! CTphpnwb,
I am not understanding what are you saying...
I am not using anytype of mysql script....
Anyway , that issue has been solved by ATli...
THank you too...
I am not understanding what are you saying...
I am not using anytype of mysql script....
Anyway , that issue has been solved by ATli...
THank you too...
|
|

New Topic/Question
Reply




MultiQuote







|