sashi34u Posted February 14, 2009 Share Posted February 14, 2009 Hi all, I have pasted the PHP code I wrote below. I do not know why, but I am getting the parse error: unexpected '>'. It says the error is on line 38. The exact line on line 38 is echo"<tr>\n Basically, I am trying to execute an sql query through PHP which tries to extract data from the mysql database and display the data in the browser. The query is running fine but I am getting the problems when I try to display the data in the browser. Can anyone help me with it? Thanks, Sashi <?php /* CONNECTS TO THE DATABASE*/ $host="********"; $user="********"; $password="********"; $dbname="********"; $cxn=mysqli_connect($host, $user, $password, $dbname); if (!$cxn=mysqli_connect($host, $user, $password, $dbname)) { $error=mysqli_error($cxn); echo "$error"; die(); } else { echo "Connection established successfully"; } $sql="select * FROM OCCUPANCY"; $data=mysqli_query($cxn,$sql); if (!$data=mysqli_query($cxn,$sql)) { $error=mysqli_error($cxn); echo "$error"; die(); } else { echo "Query sent successfully"; } echo "<br>"; echo "<html>"; echo "<h1>OCCUPANCY<h1>"; echo "<table cellspacing='5'>"; echo "<tr><td colspan='7'><hr /></td></tr>; while ($row=mysqli_fetch_array($data)) { extract($row); echo"<tr>\n <td>$building</td>\n <td>$parking_lot</td>\n <td>$month</td>\n <td>$day</td>\n <td>$occupancy</td>\n <td>$empty_spaces</td>\n <td>$special_days</td>\n </tr>\n"; echo "<tr><td colspan='7'><hr /></td></tr>\n"; } echo"</table>\n"; echo "</html>"; ?> Link to comment https://forums.phpfreaks.com/topic/145145-solved-parse-error-syntax-error-unexpected-in-cwampwwwnewphp-on-line-38/ Share on other sites More sharing options...
printf Posted February 14, 2009 Share Posted February 14, 2009 Missing a closing double quote here... echo "<tr><td colspan='7'><hr /></td></tr>; //---------------------------------------^ Link to comment https://forums.phpfreaks.com/topic/145145-solved-parse-error-syntax-error-unexpected-in-cwampwwwnewphp-on-line-38/#findComment-761819 Share on other sites More sharing options...
sashi34u Posted February 14, 2009 Author Share Posted February 14, 2009 Actually there is a double quote at that point. Link to comment https://forums.phpfreaks.com/topic/145145-solved-parse-error-syntax-error-unexpected-in-cwampwwwnewphp-on-line-38/#findComment-761823 Share on other sites More sharing options...
Maq Posted February 14, 2009 Share Posted February 14, 2009 Actually there is a double quote at that point. Well it's not in your original code, so why don't you post the correct code...? Link to comment https://forums.phpfreaks.com/topic/145145-solved-parse-error-syntax-error-unexpected-in-cwampwwwnewphp-on-line-38/#findComment-761824 Share on other sites More sharing options...
sashi34u Posted February 14, 2009 Author Share Posted February 14, 2009 Hi Maq, sorry about the misunderstanding. I was looking at the wrong place. The double quote was indeed missing . Thank you very much -sashi Link to comment https://forums.phpfreaks.com/topic/145145-solved-parse-error-syntax-error-unexpected-in-cwampwwwnewphp-on-line-38/#findComment-761830 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.