PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
$query = "SELECT CONTACT_INTERNAL_KEY FROM contacts_keys WHERE INDEX = '$i' ";
$result =mysql_query($query)
or die(mysql_error());
The error message that I am getting is: 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 'INDEX = '5'' at line 1
Line number On/Off | Expand/Contract | Select all
$query = "SELECT CONTACT_INTERNAL_KEY FROM contacts_keys WHERE INDEX = '".$i."' ";
$result =mysql_query($query) or die(mysql_error());
The extra ". and ." around the variable make it easier to read in your code.
Also I'd agree with the previous poster on naming policies.
<?php
$query = 'SELECT `CONTACT_INTERNAL_KEY` FROM `contacts_keys` WHERE `index` = 1';
?>
It is always the best idea to backtick your database, table and field names in MySQL queries. Also, when comparing integers versus strings remember that numbers do not take quotes around them, stings do, so your query above is the best typed query you have. In PHP it might look something like: