Hi I am having an issue with a MySQL query not passing a string variable.
If $pass contains only numbers it works fine.
When it contains letters I get the Cannot execute the query error.
Example:
$pass=123456 //works fine
$pass=z23456 //cannot execute the query
$_SESSION['id']=$pass; //start session
if (isset($_SESSION['id'])) {
// Query database for user information.
$query = "SELECT RepName FROM RepTable WHERE RepNumber =
".$_SESSION['id']."";
$result = mysql_query ($query) OR die ('Cannot execute the query.');
$rinfo = mysql_fetch_array ($result);
$RepInfo = $rinfo[0];
OR die ("Cannot execute the query $query");- use in development only - NEVER use it in production. This will show you that, if for example$pass="foo"your SQL statement readsSELECT RepName FROM RepTable WHERE RepNumber = foo- as you can see,foois not a valid identifier, function or number, so will need to be quoted. Assuming that RepNumber is a string type, mgraph's answer is your solution. If RepNumber is a numeric type, then you will need to validate $pass first.