Enderpanda Posted January 13, 2009 Share Posted January 13, 2009 For some reason, this code is printing a "1" before the first line, and I cannot for the life of me figure out why. Here's my code: $postcount = "9"; $rp_result = mysql_query("SELECT * FROM archive ORDER BY page_name DESC", $dbconn) or die ("Unable to run query (Recent Posts)"); $counter = "0"; while ($rp_row = mysql_fetch_assoc($rp_result)) { $rp_data1 = $rp_row["archive_title"]; $rp_data2 = $rp_row["page_name"]; $rp_cvyr = substr($rp_data2, 2, 2); $rp_cvmo = substr($rp_data2, 4, 2); $rp_cvdy = substr($rp_data2, 6, 2); $rp_date = "$rp_cvmo/$rp_cvdy"; if ($counter < $postcount) {?> <li><?=$rp_date?> - <a href="archive.php?link=<?=$rp_data2?>"><?=$rp_data1?></a></li><?=; $counter++; } } Thanks, any help would be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/140605-php-printing-unwanted-character/ Share on other sites More sharing options...
premiso Posted January 13, 2009 Share Posted January 13, 2009 if ($counter < $postcount) { echo '<li>' . $rp_date . ' - <a href="archive.php?link=' . $rp_data2 . '">' . $rp_data1 . '</a></li>'; } $counter++; Should do it. Quote Link to comment https://forums.phpfreaks.com/topic/140605-php-printing-unwanted-character/#findComment-735790 Share on other sites More sharing options...
Enderpanda Posted January 13, 2009 Author Share Posted January 13, 2009 thanks for the quick reply Unfortunately it's still there, in fact I had tried switching between using echo vs. escaping php earlier. What ticks me off is it seemingly just appeared while editing code, so I wonder if it could possibly be something else, however removing that code removes the "1" as well, so I think it's gotta be in there somewhere... Hoping there's a known bug with php or something that would explain it, because I sure can't. EDIT: By the way, the '1' is not in the database itself, I changing the search parameters, same thing everytime. If I remove the line tag, it prints the '1' with the data, if I leave the line in it prints it on the line above, so it's happening before the line tag comes in. Quote Link to comment https://forums.phpfreaks.com/topic/140605-php-printing-unwanted-character/#findComment-735797 Share on other sites More sharing options...
premiso Posted January 13, 2009 Share Posted January 13, 2009 thanks for the quick reply Unfortunately it's still there, in fact I had tried switching between using echo vs. escaping php earlier. What ticks me off is it seemingly just appeared while editing code, so I wonder if it could possibly be something else, however removing that code removes the "1" as well, so I think it's gotta be in there somewhere... Hoping there's a known bug with php or something that would explain it, because I sure can't. Is that the full code you are executing or is there more? If there is more post it, the 1 generally means a function returned true, so yea. Not sure if that is what is happening. Quote Link to comment https://forums.phpfreaks.com/topic/140605-php-printing-unwanted-character/#findComment-735800 Share on other sites More sharing options...
trq Posted January 13, 2009 Share Posted January 13, 2009 Is this your entire code? Often this will happen when people attempt to echo an require (or include), eg; echo require "foo.php"; Quote Link to comment https://forums.phpfreaks.com/topic/140605-php-printing-unwanted-character/#findComment-735801 Share on other sites More sharing options...
Enderpanda Posted January 13, 2009 Author Share Posted January 13, 2009 (You guys are awesome btw) Hrrmmm, no that wasn't everything, I was just trying to put it where I personally thought the problem was. I think you are right, I'm pretty sure it has to do something with include, though I'm pretty sure I escaped all the echo statements properly. Here's the entire home.php and layout.php code. The piece I had posted earlier is towards the bottom of 'layout.php'. God I feel naked now... home.php <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Home</title> </head> <body> <?php include ("config/ep_config.php"); include ("config/ep_connect.php"); include ("config/var.php"); /* */ $type = "home"; $table1 = "archive"; $search = "page_name"; $title = "archive_title"; $content1 = "archive_content"; $usedate = "yes"; $signature = "yes"; $linkhead = "yes"; /* */ $homeresult = mysql_query("SELECT * FROM $table1 ORDER BY $search DESC", $dbconn) or die ("Unable to run query (home1.php)"); $homerow = mysql_fetch_assoc($homeresult); $current = $homerow["page_name"]; /* */ $pageresult = mysql_query("SELECT * FROM $table1 WHERE $search='$current'", $dbconn) or die ("Unable to run query (home2.php)"); $pagerow = mysql_fetch_assoc($pageresult); /* */ $date = $pagerow[$search]; $titleoutput = $pagerow[$title]; $contentoutput = $pagerow[$content1]; /* */ include ("config/layout.php") ?> </body> </html> layout.php <title>EP Layout</title> <link rel="stylesheet" type="text/css" href="config/ep_css.css"> <script type="text/javascript" src="config/js/ep_js.js"></script> <script type="text/javascript" src="config/js/shadowbox/adapter/shadowbox-base.js"></script> <script type="text/javascript" src="config/js/shadowbox/shadowbox.js"></script> <script type="text/javascript"> Shadowbox.loadSkin('classic', 'config/js/shadowbox/skin'); Shadowbox.loadLanguage('en', 'config/js/shadowbox/lang'); Shadowbox.loadPlayer(['flv', 'html', 'iframe', 'img', 'qt', 'swf', 'wmp'], 'config/js/shadowbox/player'); window.onload = function(){ Shadowbox.init(); }; </script> </head> <body> <div id="nav"> <ul> <li><a href="<?=$p1?>" onfocus="this.blur()"><?=$p1t?></a></li> <li><a href="<?=$p2?>" onfocus="this.blur()"><?=$p2t?></a></li> <li><a href="<?=$p3?>" onfocus="this.blur()"><?=$p3t?></a></li> <li><a href="<?=$p4?>" onfocus="this.blur()"><?=$p4t?></a></li> <li><a href="<?=$p5?>" onfocus="this.blur()"><?=$p5t?></a></li> <li><a href="<?=$p6?>" onfocus="this.blur()"><?=$p6t?></a></li> </ul> </div> <div id="spacer"></div> <div id="leftwrap"> <div id="leftheader"><span class="title"><a href="http://delicious.com/enderpanda" target="_blank">Links</a></span></div> <div id="leftbar"> <table width="138" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="8" bgcolor="#181818"> </td> <td align="center" valign="top"><div id="leftbarhole"></div></td> <td width="8" bgcolor="#181818"> </td> </tr> </table> </div> <div id="leftbody"></div> <div id="leftheader"><span class="title">Friends</span></div> <div id="leftbar"> <table width="138" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="8" bgcolor="#181818"> </td> <td align="center" valign="top"><div id="leftbarhole"></div></td> <td width="8" bgcolor="#181818"> </td> </tr> </table> </div> <div id="leftbody"> <ul> <li><a href="#">Fwiend 1</a></li> <li><a href="#">Fwiend 2</a></li> <li><a href="#">Fwiend 3</a></li> <li><a href="#">Fwiend 4</a></li> <li><a href="#">Fwiend 5</a></li> <li><a href="#">Fwiend 6</a></li> </ul> </div></div> <div id="contentwrap"><div id="currenttitle"><? if ($linkhead=="yes") { ?><span class="title"><a href ="archive.php?link=<?=$date?>"><?=$titleoutput?></a></span><?=; } else { ?><span class="title"><?=$titleoutput?></span><?=; } if ($usedate == yes) { $dateoutput = $date; $cvyr = substr($dateoutput, 2, 2); $cvmo = substr($dateoutput, 4, 2); $cvdy = substr($dateoutput, 6, 2); $cvdate = "$cvmo/$cvdy/$cvyr"; echo "$cvdate";}?></div> <div id="currentbar"></div> <div id="currentcontent"><? /* */ echo $contentoutput."<br>"; if ($type == arindex) { include ("output.php"); } if ($type == downloads) { include ("output.php"); } if ($type == galindex) { include ("output.php"); } if ($type == subgal) { include ("output.php"); } ?></div><div id="postend"></div></div> <div id="rightwrap"> <div id="rightheader"><span class="title">Recent Posts</span></div> <div id="rightbar"> <table width="196" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="16" bgcolor="#181818"> </td> <td align="center" valign="top"><div id="rightbarhole"></div></td> <td width="16" bgcolor="#181818"> </td> </tr> </table> </div> <div id="rightbody"><ul><?= $rp_result = mysql_query("SELECT * FROM archive ORDER BY page_name DESC", $dbconn) or die ("Unable to run query (Recent Posts.php)"); $counter = "0"; while ($rp_row = mysql_fetch_assoc($rp_result)) { $rp_data1 = $rp_row["archive_title"]; $rp_data2 = $rp_row["page_name"]; $rp_cvyr = substr($rp_data2, 2, 2); $rp_cvmo = substr($rp_data2, 4, 2); $rp_cvdy = substr($rp_data2, 6, 2); $rp_date = "$rp_cvmo/$rp_cvdy"; if ($counter < $postcount) { echo '<li>' . $rp_date . ' - <a href="archive.php?link=' . $rp_data2 . '">' . $rp_data1 . '</a></li>'; } $counter++; } ?></ul> </div></div></div> <div id="spacer"></div> <div id="rightwrap"> <div id="rightheader"><span class="title">Contact</span></div> <div id="rightbar"> <table width="196" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="16" bgcolor="#181818"> </td> <td align="center" valign="top"><div id="rightbarhole"></div></td> <td width="16" bgcolor="#181818"> </td> </tr> </table> </div> <div id="rightbody"> <div id="twitter_div"> <h2 style="display: none;" >Twitter Updates</h2> <ul id="twitter_update_list"></ul> </div></div></div></div> <div id="footerwrap"><div id="footer"><a href="<?=$p1?>"><?=$p1t?></a> - <a href="<?=$p2?>"><?=$p2t?></a> - <a href="<?=$p3?>"><?=$p3t?></a> - <a href="<?=$p4?>"><?=$p4t?></a> - <a href="<?=$p5?>"><?=$p5t?></a> - <a href="<?=$p6?>"><?=$p6t?></a></div></div> <script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script> <script type="text/javascript" src="http://twitter.com/statuses/user_timeline/Enderpanda.json?callback=twitterCallback2&count=5"></script> Quote Link to comment https://forums.phpfreaks.com/topic/140605-php-printing-unwanted-character/#findComment-735810 Share on other sites More sharing options...
Enderpanda Posted January 13, 2009 Author Share Posted January 13, 2009 Oh and yes I know I'm using a couple tables as spacers like a noob, I'm gonna get rid of those soon. Quote Link to comment https://forums.phpfreaks.com/topic/140605-php-printing-unwanted-character/#findComment-735811 Share on other sites More sharing options...
PFMaBiSmAd Posted January 13, 2009 Share Posted January 13, 2009 You need to do a "view source" of the page in your browser and look (or post) exactly where the "1" is at in it on the page in order to find what part of the code is outputting it. You also have two sets of <title></title> </head> <body> tags. One set in home.php and one set in layout.php. You need to correct this so that your page is valid HTML. Quote Link to comment https://forums.phpfreaks.com/topic/140605-php-printing-unwanted-character/#findComment-735820 Share on other sites More sharing options...
dawsba Posted January 13, 2009 Share Posted January 13, 2009 It would be a good idea if you could post the html output, plus if you can post the include files from home.php that would be helpfull. Quote Link to comment https://forums.phpfreaks.com/topic/140605-php-printing-unwanted-character/#findComment-735837 Share on other sites More sharing options...
Enderpanda Posted January 13, 2009 Author Share Posted January 13, 2009 so that your page is valid HTML. Dare to dream I still have to go thru and do some finalization, right now things are just sort of a mock-up to get problems solved. Thank you for the heads-up tho, I corrected that (and welcome any other suggestions!). Here's the view source, I removed some database output and info to help clarify (replaced with ***content***), I added a red arrow and highlighted where the '1' is popping up: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Home</title> </head> <body> <link rel="stylesheet" type="text/css" href="config/ep_css.css"> <script type="text/javascript" src="config/js/ep_js.js"></script> <script type="text/javascript" src="config/js/shadowbox/adapter/shadowbox-base.js"></script> <script type="text/javascript" src="config/js/shadowbox/shadowbox.js"></script> <script type="text/javascript"> Shadowbox.loadSkin('classic', 'config/js/shadowbox/skin'); Shadowbox.loadLanguage('en', 'config/js/shadowbox/lang'); Shadowbox.loadPlayer(['flv', 'html', 'iframe', 'img', 'qt', 'swf', 'wmp'], 'config/js/shadowbox/player'); window.onload = function(){ Shadowbox.init(); }; </script> <div id="nav"> <ul> <li><a href="home.php" onfocus="this.blur()">Home</a></li> <li><a href="archive.php" onfocus="this.blur()">Archive</a></li> <li><a href="gallery.php" onfocus="this.blur()">Gallery</a></li> <li><a href="music.php" onfocus="this.blur()">Music</a></li> <li><a href="downloads.php" onfocus="this.blur()">Downloads</a></li> <li><a href="info.php" onfocus="this.blur()">Info</a></li> </ul> </div> <div id="spacer"></div> <div id="leftwrap"> <div id="leftheader"><span class="title"><a href="***content***" target="_blank">Links</a></span></div> <div id="leftbar"> <table width="138" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="8" bgcolor="#181818"> </td> <td align="center" valign="top"><div id="leftbarhole"></div></td> <td width="8" bgcolor="#181818"> </td> </tr> </table> </div> <div id="leftbody"></div> <div id="leftheader"><span class="title">Friends</span></div> <div id="leftbar"> <table width="138" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="8" bgcolor="#181818"> </td> <td align="center" valign="top"><div id="leftbarhole"></div></td> <td width="8" bgcolor="#181818"> </td> </tr> </table> </div> <div id="leftbody"> <ul> <li><a href="#">Fwiend 1</a></li> <li><a href="#">Fwiend 2</a></li> <li><a href="#">Fwiend 3</a></li> <li><a href="#">Fwiend 4</a></li> <li><a href="#">Fwiend 5</a></li> <li><a href="#">Fwiend 6</a></li> </ul> </div></div> <div id="contentwrap"><div id="currenttitle"><span class="title"><a href ="archive.php?link=20090107">***content***</a></span>***content***</div> <div id="currentbar"></div> <div id="currentcontent"> ***content***</div><div id="postend"></div></div> <div id="rightwrap"> <div id="rightheader"><span class="title">Recent Posts</span></div> <div id="rightbar"> <table width="196" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="16" bgcolor="#181818"> </td> <td align="center" valign="top"><div id="rightbarhole"></div></td> <td width="16" bgcolor="#181818"> </td> </tr> </table> </div> ----><div id="rightbody"><ul>1<li>01/07 - <a href="archive.php?link=20090107">***content***</a></li><li>12/11 - <a href="archive.php?link=20081211">***content***</a></li><li>11/27 - <a href="archive.php?link=20081127">***content***</a></li><li>11/11 - <a href="archive.php?link=20081111">***content***</a></li><li>11/05 - <a href="archive.php?link=20081105">***content***</a></li><li>11/02 - <a href="archive.php?link=20081102">***content***</a></li><li>10/31 - <a href="archive.php?link=20081031">***content***</a></li><li>10/20 - <a href="archive.php?link=20081020">***content***</a></li><li>10/19 - <a href="archive.php?link=20081019">***content***</a></li></ul> </div></div></div> <div id="spacer"></div> <div id="rightwrap"> <div id="rightheader"><span class="title">Contact</span></div> <div id="rightbar"> <table width="196" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="16" bgcolor="#181818"> </td> <td align="center" valign="top"><div id="rightbarhole"></div></td> <td width="16" bgcolor="#181818"> </td> </tr> </table> </div> <div id="rightbody"> <div id="twitter_div"> <h2 style="display: none;" >Twitter Updates</h2> <ul id="twitter_update_list"></ul> </div></div></div></div> <div id="footerwrap"><div id="footer"><a href="home.php">Home</a> - <a href="archive.php">Archive</a> - <a href="gallery.php">Gallery</a> - <a href="music.php">Music</a> - <a href="downloads.php">Downloads</a> - <a href="info.php">Info</a></div></div> <script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script> <script type="text/javascript" src="http://twitter.com/statuses/user_timeline/***content***.json?callback=twitterCallback2&count=5"></script></body> </html> home.php <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Enderpanda.com -- Home</title> </head> <body> <?php include ("config/ep_config.php"); include ("config/ep_connect.php"); include ("config/var.php"); /* */ $type = "home"; $table1 = "archive"; $search = "page_name"; $title = "archive_title"; $content1 = "archive_content"; $usedate = "yes"; $signature = "yes"; $linkhead = "yes"; /* */ $homeresult = mysql_query("SELECT * FROM $table1 ORDER BY $search DESC", $dbconn) or die ("Unable to run query (home1.php)"); $homerow = mysql_fetch_assoc($homeresult); $current = $homerow["page_name"]; /* */ $pageresult = mysql_query("SELECT * FROM $table1 WHERE $search='$current'", $dbconn) or die ("Unable to run query (home2.php)"); $pagerow = mysql_fetch_assoc($pageresult); /* */ $date = $pagerow[$search]; $titleoutput = $pagerow[$title]; $contentoutput = $pagerow[$content1]; /* */ include ("config/layout.php") ?> </body> </html> layout.php (removed the extra tags) <link rel="stylesheet" type="text/css" href="config/ep_css.css"> <script type="text/javascript" src="config/js/ep_js.js"></script> <script type="text/javascript" src="config/js/shadowbox/adapter/shadowbox-base.js"></script> <script type="text/javascript" src="config/js/shadowbox/shadowbox.js"></script> <script type="text/javascript"> Shadowbox.loadSkin('classic', 'config/js/shadowbox/skin'); Shadowbox.loadLanguage('en', 'config/js/shadowbox/lang'); Shadowbox.loadPlayer(['flv', 'html', 'iframe', 'img', 'qt', 'swf', 'wmp'], 'config/js/shadowbox/player'); window.onload = function(){ Shadowbox.init(); }; </script> <div id="nav"> <ul> <li><a href="<?=$p1?>" onfocus="this.blur()"><?=$p1t?></a></li> <li><a href="<?=$p2?>" onfocus="this.blur()"><?=$p2t?></a></li> <li><a href="<?=$p3?>" onfocus="this.blur()"><?=$p3t?></a></li> <li><a href="<?=$p4?>" onfocus="this.blur()"><?=$p4t?></a></li> <li><a href="<?=$p5?>" onfocus="this.blur()"><?=$p5t?></a></li> <li><a href="<?=$p6?>" onfocus="this.blur()"><?=$p6t?></a></li> </ul> </div> <div id="spacer"></div> <div id="leftwrap"> <div id="leftheader"><span class="title"><a href="***content***" target="_blank">Links</a></span></div> <div id="leftbar"> <table width="138" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="8" bgcolor="#181818"> </td> <td align="center" valign="top"><div id="leftbarhole"></div></td> <td width="8" bgcolor="#181818"> </td> </tr> </table> </div> <div id="leftbody"></div> <div id="leftheader"><span class="title">Friends</span></div> <div id="leftbar"> <table width="138" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="8" bgcolor="#181818"> </td> <td align="center" valign="top"><div id="leftbarhole"></div></td> <td width="8" bgcolor="#181818"> </td> </tr> </table> </div> <div id="leftbody"> <ul> <li><a href="#">Fwiend 1</a></li> <li><a href="#">Fwiend 2</a></li> <li><a href="#">Fwiend 3</a></li> <li><a href="#">Fwiend 4</a></li> <li><a href="#">Fwiend 5</a></li> <li><a href="#">Fwiend 6</a></li> </ul> </div></div> <div id="contentwrap"><div id="currenttitle"><? if ($linkhead=="yes") { ?><span class="title"><a href ="archive.php?link=<?=$date?>"><?=$titleoutput?></a></span><?=; } else { ?><span class="title"><?=$titleoutput?></span><?=; } if ($usedate == yes) { $dateoutput = $date; $cvyr = substr($dateoutput, 2, 2); $cvmo = substr($dateoutput, 4, 2); $cvdy = substr($dateoutput, 6, 2); $cvdate = "$cvmo/$cvdy/$cvyr"; echo "$cvdate";}?></div> <div id="currentbar"></div> <div id="currentcontent"><? /* */ echo $contentoutput."<br>"; if ($type == arindex) { include ("output.php"); } if ($type == downloads) { include ("output.php"); } if ($type == galindex) { include ("output.php"); } if ($type == subgal) { include ("output.php"); } ?></div><div id="postend"></div></div> <div id="rightwrap"> <div id="rightheader"><span class="title">Recent Posts</span></div> <div id="rightbar"> <table width="196" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="16" bgcolor="#181818"> </td> <td align="center" valign="top"><div id="rightbarhole"></div></td> <td width="16" bgcolor="#181818"> </td> </tr> </table> </div> <div id="rightbody"><ul><?= $rp_result = mysql_query("SELECT * FROM archive ORDER BY page_name DESC", $dbconn) or die ("Unable to run query (Recent Posts.php)"); $counter = "0"; while ($rp_row = mysql_fetch_assoc($rp_result)) { $rp_data1 = $rp_row["archive_title"]; $rp_data2 = $rp_row["page_name"]; $rp_cvyr = substr($rp_data2, 2, 2); $rp_cvmo = substr($rp_data2, 4, 2); $rp_cvdy = substr($rp_data2, 6, 2); $rp_date = "$rp_cvmo/$rp_cvdy"; if ($counter < $postcount) { echo '<li>' . $rp_date . ' - <a href="archive.php?link=' . $rp_data2 . '">' . $rp_data1 . '</a></li>'; } $counter++; } ?></ul> </div></div></div> <div id="spacer"></div> <div id="rightwrap"> <div id="rightheader"><span class="title">Contact</span></div> <div id="rightbar"> <table width="196" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="16" bgcolor="#181818"> </td> <td align="center" valign="top"><div id="rightbarhole"></div></td> <td width="16" bgcolor="#181818"> </td> </tr> </table> </div> <div id="rightbody"> <div id="twitter_div"> <h2 style="display: none;" >Twitter Updates</h2> <ul id="twitter_update_list"></ul> </div></div></div></div> <div id="footerwrap"><div id="footer"><a href="<?=$p1?>"><?=$p1t?></a> - <a href="<?=$p2?>"><?=$p2t?></a> - <a href="<?=$p3?>"><?=$p3t?></a> - <a href="<?=$p4?>"><?=$p4t?></a> - <a href="<?=$p5?>"><?=$p5t?></a> - <a href="<?=$p6?>"><?=$p6t?></a></div></div> <script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script> <script type="text/javascript" src="http://twitter.com/statuses/user_timeline/***content***.json?callback=twitterCallback2&count=5"></script> Quote Link to comment https://forums.phpfreaks.com/topic/140605-php-printing-unwanted-character/#findComment-735839 Share on other sites More sharing options...
dawsba Posted January 13, 2009 Share Posted January 13, 2009 in layout.php delete the equals sign here ---> <div id="rightbody"><ul><?= Quote Link to comment https://forums.phpfreaks.com/topic/140605-php-printing-unwanted-character/#findComment-735845 Share on other sites More sharing options...
PFMaBiSmAd Posted January 13, 2009 Share Posted January 13, 2009 <div id="rightbody"><ul><?= $rp_result = mysql_query("SELECT * FROM archive ORDER BY page_name DESC", $dbconn) <?= is equivalent to <?php echo. So, that code is echoing $rp_result I seriously recommend that you don't use short open tags <? and <?= Always use <?php and <?php echo Quote Link to comment https://forums.phpfreaks.com/topic/140605-php-printing-unwanted-character/#findComment-735846 Share on other sites More sharing options...
Enderpanda Posted January 13, 2009 Author Share Posted January 13, 2009 It would be a good idea if you could post the html output, plus if you can post the include files from home.php that would be helpfull. Here's the included files, with sensitive info removed ep_config.php <?php $dbhost = "***removed***"; $dbuname = "***removed***"; $dbpass = "***removed***"; $dbname = "***removed***"; ?> ep_connect.php <?php $dbconn = mysql_connect($dbhost, $dbuname, $dbpass) or die ("Unable to connect"); mysql_select_db ($dbname, $dbconn) or die ("Unable to select database"); ?> var.php <?= $blank = ""; $p1 = "home.php"; $p1t = "Home"; $p2 = "archive.php"; $p2t = "Archive"; $p3 = "gallery.php"; $p3t = "Gallery"; $p4 = "music.php"; $p4t = "Music"; $p5 = "downloads.php"; $p5t = "Downloads"; $p6 = "info.php"; $p6t = "Info"; $imgdir = "../data/images/"; $wowdir = "../data/wowimages/"; $downdir = "../data/downloads/"; $icondir = "../data/icons/"; $galdir = "../data/gallery/"; $endermail = "***removed***"; $delicious - "***removed***"; $postcount = "9"; ?> By the way, I added the 'blank' variable because it kept printing out the first one from var.php, why it was doing that is another mystery, not a perfect fix but works for now. Quote Link to comment https://forums.phpfreaks.com/topic/140605-php-printing-unwanted-character/#findComment-735847 Share on other sites More sharing options...
dawsba Posted January 13, 2009 Share Posted January 13, 2009 its the same reason PFMaBiSmAd is very right try to use <?php short tags can cause problems as proved here. have fun Quote Link to comment https://forums.phpfreaks.com/topic/140605-php-printing-unwanted-character/#findComment-735849 Share on other sites More sharing options...
Enderpanda Posted January 13, 2009 Author Share Posted January 13, 2009 in layout.php delete the equals sign here ---> <div id="rightbody"><ul><?= <?= is equivalent to <?php echo. So, that code is echoing $rp_result That fixed it! Thank you soooo much everyone, you rock and/or roll! I'm still learning and I hate getting caught up stuff like that. I seriously recommend that you don't use short open tags <? and <?= Always use <?php and <?php echo I absolutely will in the future, thank you very much for the advice! If you guys could help with one last thing while I have u guys here, is there a way to combine these statements? Every time I try things go all broke-like.. if ($type == arindex) { include ("output.php"); } if ($type == downloads) { include ("output.php"); } if ($type == galindex) { include ("output.php"); } if ($type == subgal) { include ("output.php"); } Quote Link to comment https://forums.phpfreaks.com/topic/140605-php-printing-unwanted-character/#findComment-735854 Share on other sites More sharing options...
dawsba Posted January 13, 2009 Share Posted January 13, 2009 switch ($type) { case "arindex": include ("output.php"); break; case "downloads": include ("output.php"); break; case "galindex": include ("output.php"); break; case "subgal": include ("output.php"); break; } This'll sort it Have fun. Quote Link to comment https://forums.phpfreaks.com/topic/140605-php-printing-unwanted-character/#findComment-735868 Share on other sites More sharing options...
Enderpanda Posted January 13, 2009 Author Share Posted January 13, 2009 Woot! Thx! Problem(s) solved! Btw, the echo issue also tells me why the first variable in var.php was printing. When I'm a big famous web developer I'll tell everyone I owe it all to PHPFreaks Quote Link to comment https://forums.phpfreaks.com/topic/140605-php-printing-unwanted-character/#findComment-735875 Share on other sites More sharing options...
xtopolis Posted January 13, 2009 Share Posted January 13, 2009 If you're outputting the same thing for all those pages, you could save a few lines of code: $allowedTypes = array('arindex','downloads','galindex','subgal'); if(in_array($type,$allowedTypes)){ include 'output.php'; } dawsba's suggestion would be better suited to if you had different pages that needed to include different things. Also, if you're being indiscriminate about $type, you can just do: if(!empty($type)){ include 'output.php' } Quote Link to comment https://forums.phpfreaks.com/topic/140605-php-printing-unwanted-character/#findComment-735892 Share on other sites More sharing options...
Enderpanda Posted January 13, 2009 Author Share Posted January 13, 2009 Ah cool, thx! That actually really helps, much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/140605-php-printing-unwanted-character/#findComment-735953 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.