HaZaRd420 Posted June 9, 2006 Share Posted June 9, 2006 I am having trouble with my code and getting an error on a line that just has </html> on it.[code]<?php$func = $_GET["func"];$id = $_GET["id"];//hazards test//include('config.php');$rs = mysql_connect( "$host","$user","$pass" ) or die(mysql_error());$rs = mysql_select_db( "$db" );$rs = mysql_query($sql) or die(mysql_error());if($func === 'view'){$sql="SELECT * FROM news where id='1'";$rs = mysql_query($sql_staff) or die(mysql_error()); echo"<table id=\"Table_01\" width=\"314\" height=\"100\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"> <tr> <td> <table background=\"box2/images/index_01.gif\" width="314" height=\"23\"><tr><td><b>'.$row["subject"].'</b><br><br><div align=\"right\">Posted by : <b><u>'.$row["author"].'</u></b> on <i>'.$row["date"].'</i></div></td></tr></table> </td> </tr> <tr> <td> <table background=\"box2/images/index_02.gif\" width=\"314\" height=\"72\" cellpadding=\"5\"><tr valign="top"><td>'.$row["content"].'</td></tr></table> </td> </tr> <tr> <td> <img src=\"box2/images/index_03.gif\" width=\"314\" height=\"5\" alt=\"\"></td> </tr></table>';}?>[/code]any way someone can sort this out for me? All i want to do is display the data from that row. But im gettiing this error // Parse error: syntax error, unexpected $end in /data/11/0/78/25/730677/user/745722/htdocs/gau/test/news.php on line 99thanks. Quote Link to comment https://forums.phpfreaks.com/topic/11571-func-and-line-error-help/ Share on other sites More sharing options...
joquius Posted June 9, 2006 Share Posted June 9, 2006 unexpected end happens when something is still open. this could be a line, if, loop, etc.a few notes which could all be culprits:$func = $_GET["func"]; // please use if (isset ($_GET)) $_GET = $var; // as this can cause errors, not critical but anywaymysql_connect( "$host","$user","$pass" ) // this does not need quotes for the $stringsmysql_select_db( "$db" ); // neither does this$rs = mysql_query($sql_staff) or die(mysql_error()); // where is $sql_staff set?'.$row["subject"].' // change this to ".$row['subject']." as you have opened the echo on "With so much html you are better escaping php. this can simply things a lot.<?if ($page) {?><html></html><?}?>No need to addslashes so much.Also $_var["attrib"] is better as $_var['attrib'] if you're using echo ""; standardize your quotes Quote Link to comment https://forums.phpfreaks.com/topic/11571-func-and-line-error-help/#findComment-43605 Share on other sites More sharing options...
HaZaRd420 Posted June 9, 2006 Author Share Posted June 9, 2006 K so escaping php is that a differnt method? if so, the if ($page) would be the name of my page that im creating? Quote Link to comment https://forums.phpfreaks.com/topic/11571-func-and-line-error-help/#findComment-43610 Share on other sites More sharing options...
joquius Posted June 9, 2006 Share Posted June 9, 2006 The if ($page) was just an example of escaping to html within php. I'll show you what your page would look like:[code]<?php$func = (isset ($_GET['func'])) ? $_GET['func'] : "";$id = (isset ($_GET['id'])) ? $_GET['id'] : "";//hazards test//include ("config.php");$rs = mysql_connect ($host, $user, $pass) or die (mysql_error ());$rs = mysql_select_db ($db);$rs = mysql_query ($sql) or die (mysql_error ());if($func === "view"){ $sql_staff = "SELECT * FROM news where id=\'1\'"; // the issue was here, no slashes on the quotes inside the query $rs = mysql_query ($sql_staff) or die (mysql_error()); // $sql_staff was not defined??><table id="Table_01" width="314" height="100" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <table background="box2/images/index_01.gif" width="314" height="23"> <tr> <td><b><?=$row['subject']?></b><br><br><div align="right">Posted by : <b><u><?=$row['author']?></u></b> on <i><?=$row['date']?></i></div></td> </tr> </table> </td> </tr> <tr> <td> <table background="box2/images/index_02.gif" width="314" height="72" cellpadding="5"> <tr valign="top"> <td><?=$row['content']?></td> </tr> </table> </td> </tr> <tr> <td> <img src="box2/images/index_03.gif" width="314" height="5" alt=""> </td> </tr></table><?}?>[/code]As you can see, within the html we do <?=$var?> to get php vars Quote Link to comment https://forums.phpfreaks.com/topic/11571-func-and-line-error-help/#findComment-43611 Share on other sites More sharing options...
HaZaRd420 Posted June 9, 2006 Author Share Posted June 9, 2006 Sweet man I got it! Thanks alot for sparing your time to help me joquius. I may ask you for a few more questions in the future. Do you have any sort of instantmessaging program? if so contact me with a pm or somthing ! Thanks alot. Quote Link to comment https://forums.phpfreaks.com/topic/11571-func-and-line-error-help/#findComment-43613 Share on other sites More sharing options...
Fyorl Posted June 9, 2006 Share Posted June 9, 2006 a quick question related to this. Why are you using === instead of == as === just means equivalent to. Unless there's some special feature of the === operator when comparing strings (such as case-insensitive?) that I'm not aware of Quote Link to comment https://forums.phpfreaks.com/topic/11571-func-and-line-error-help/#findComment-43626 Share on other sites More sharing options...
joquius Posted June 9, 2006 Share Posted June 9, 2006 quoted from php.net:Note on ===:While the php documentation says that, basically,($a===$b) is the same as ($a==$b && gettype($a) == gettype($b)),this is not true.The difference between == and === is that === never does any type conversion. So, while, according to documentation, ("+0.1" === ".1") should return true (because both are strings and == returns true), === actually returns false (which is good).Edit: didn't want to post again. Obviously not needed but it's not my script. Quote Link to comment https://forums.phpfreaks.com/topic/11571-func-and-line-error-help/#findComment-43629 Share on other sites More sharing options...
Fyorl Posted June 9, 2006 Share Posted June 9, 2006 but if you're comparing it to a string, 'view', the only possible thing that could match that would be another 'view'. Quote Link to comment https://forums.phpfreaks.com/topic/11571-func-and-line-error-help/#findComment-43630 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.