嗨,我遇到了 MySQL 查询未传递字符串变量的问题。
如果$pass
仅包含数字,则可以正常工作。当它包含字母时,我得到Cannot execute the query
错误。
例子:
$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];