With the following test script I receive and error: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" > <head><title>Test MySQL</title></head> <body> <!-- mysql_up.php --> <?php $host=â€localhostâ€; $user=â€ma56779_testâ€; $password=â€testâ€; mysql_connect($host,$user,$password); $sql=â€show statusâ€; $result = mysql_query($sql); if ($result == 0) echo “<b>Error “ . mysql_errno() . “: “ . mysql_error() . “</b>â€; else { ?> <!-- Table that displays the results --> <table border=â€1â€> <tr><td><b>Variable_name</b></td><td><b>Value</b> </td></tr> <?php for ($i = 0; $i < mysql_num_rows($result); $i++) { echo “<TR>â€; $row_array = mysql_fetch_row($result); for ($j = 0; $j < mysql_num_fields($result); $j++) { echo “<TD>†. $row_array[$j] . “</td>â€; } echo “</tr>â€; } ?> </table> <?php } ?> </body></html> Code (markup): Error: Parse error: syntax error, unexpected T_STRING in /home/ma56779/public_html/miscstuff/projects/mysql_up.php on line 16 Code (markup): how do I fix this? Thanks for the help!
This kind of error is a very common thing and you have get used to it to be able to debug easily. It means the PHP engine confused with your syntax 'grammar' when it tried to translate your command. It can be missing semi colon, brackets or else. It gave the direction for you already that you must find line 16 to fix the error. I found on around that line, it seemed you missed the SQL command as your query instead you filled it with string "show status". mysql_connect($host,$user,$password); $sql=â€show statusâ€; $result = mysql_query($sql); PHP: