EATON106 Posted September 4, 2009 Share Posted September 4, 2009 Hi, I have a really basis form: <form action="results.php" method="post"> <input type="checkbox" value="1" name="pizza">Pizza</input><br> <input type="submit" name="submit" value="Find Food"> </form> I want to find all records where the value of 1 (pizza) is in a table column called TYPES. This is my code in results.php below: <?php $con = mysql_connect("localhost","username","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("infostore", $con); $pizza = $_POST["pizza"]; $result = mysql_query("SELECT * FROM storedata WHERE types = .$pizza."); while($row = mysql_fetch_array($result)) However, this doesn't work and I get the following message: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/vhosts/findsomefood.co.uk/httpdocs/search/results.php on line 41 I assume I have the mysql_query wrong, but I am not certain as this is new to me. Thanks. Link to comment https://forums.phpfreaks.com/topic/173094-solved-using-forms-to-interrogate-mysql-table/ Share on other sites More sharing options...
EATON106 Posted September 4, 2009 Author Share Posted September 4, 2009 Sorted it, my array needed ' instead of " and the query needed ' instead of . Phew. Link to comment https://forums.phpfreaks.com/topic/173094-solved-using-forms-to-interrogate-mysql-table/#findComment-912366 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.