Jump to content

PHP SQL SELECT Problem


skaero

Recommended Posts

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 1
I 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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...