I seem to be having trouble with my php code. I have constructed the query using phpMyAdmin where it works without any problems. However, once I insert the sql query into this php code it does not seem to work at all.
<?php
define('dbname',"dbname");
define('dbusername',"dbusername");
define('dbpass',"pass");
define('dbhost','10.10.10.1');
mysql_connect(dbhost,dbusername,dbpass);
echo "Connected to MySQL<br>";
mysql_select_db(dbname);
echo "Connected to Database<br>";
$q=mysql_query("SELECT * FROM tube WHERE code = B");
while($row=mysql_fetch_assoc($sql))
$output[]=$row;
print(json_encode($output));
mysql_close();
?>
I keep getting the following error message when I try and execute the php script using my web browser.
HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfil the request.
Any help regarding the coding would be helpful. Also the primary key is set to auto incremental if that makes any difference?
Thanks