user3100192
user3100192

Reputation: 11

mysqli select query error 1064

trying to make a query:

$word = $mysqli->real_escape_string($words[$value]);
$valor = $mysqli->real_escape_string($value);

$query = $mysqli->query("SELECT 'w_id' FROM '$valor' WHERE word='$word'");

But the result is :

Error (1064) 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 ''eng' WHERE word='msms'' at line 1

here eng is a value of $valor

I tried allready a lot of possibilities to insert the variable, and changed names of tables, but nothing helps

tried '".$valor."' as well

Upvotes: 1

Views: 4246

Answers (1)

user632287
user632287

Reputation:

Do not put quotation marks around the table/field names:

$query = $mysqli->query("SELECT w_id FROM " . $valor . " WHERE word = '" . $word . "'");

Upvotes: 1

Related Questions