I am trying to make a simple query to a small MYSQL table, but when I insert the Where clause, I suddenly get an invalid query error (added a while(mysql_fetch_array ){}
when working without the where). The MYSQL console gives a 1064 (syntax) error, however, I checked the MYSQL documentation and I am using the proper syntax as far as I can determine.
<?php
$ind=rand(1,3);
$quote=Null;
$sign=Null;
$afil=Null;
$con=mysql_connect(localhost,root,********);//connect to database
mysql_select_db("phone_site",$con);//select table
$query="SELECT * FROM quotes WHERE index=$ind";//get the row for that index
$data=mysql_query($query);
//print out text
print ("<p id=\"quote\">" . $data['quote'] . "</p>");
print ("<p id=\"ename\">" . $data['sign'] . "</p>");
print ("<p id=\"afill\">-- " . $data['afil'] . "</p>");
mysql_close($con);//close connection
?>
Anyone know what the problem is? I'm using XAMPP. Is there something wrong with its MYSQL?