skaero Posted June 2, 2008 Share Posted June 2, 2008 Well I posted here because I think its a SQL problem not a PHP one. When I run this it says: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id = '1' AND place = '1'' at line 1I can't find AND being able to be used in a SELECT but thats what I need it to do.Note: the values that were in the posts were not 1$check_result = mysql_query("SELECT * FROM table WHERE id='$_POST[id]' AND place='$_POST[place]'");$check_rows = mysql_num_rows($check_result);if ($check_rows >= "1") {echo = 'No';} else {echo = 'Yes';} Thanks!(Sorry for bad English I been working on this for hours!) Link to comment Share on other sites More sharing options...
Synook Posted June 2, 2008 Share Posted June 2, 2008 table is a reserved keyword in MySQL, try $check_result = mysql_query("SELECT * FROM `table` WHERE id='{$_POST['id']}' AND place='{$_POST['place']}'"); Link to comment Share on other sites More sharing options...
skaero Posted June 2, 2008 Author Share Posted June 2, 2008 Nope same error. Link to comment Share on other sites More sharing options...
king Posted June 3, 2008 Share Posted June 3, 2008 First of all, why are you giving a table the name 'table'? Give it a better name such as users, reviews, products, customers, etc.Second of all, the query should execute successfully when you put backticks around the table name (in this case, `table`).mysql_query("SELECT * FROM `table` WHERE id='$_POST[id]' AND place='$_POST[place]'"); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.