select4:34
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 'SELECT * FROM categori WHERE auto_id = 34' at line 1代码如下:
 $select4 = checkVar($_REQUEST["select4"]);
 
 echo "select4:".$select4."<br>";
 
 $str_sql_category_count1 = "SELECT COUNT(*) AS totalrows FROM categori WHERE auto_id = ".$select4;
 $result_category_count1 = mysql_query($str_sql_category_count1,$connect_db) or die(mysql_error()); 
 $row_category_count1 = mysql_fetch_assoc($result_category_count1); 
 $totalRows_1 = $row_category_count1['totalrows']; 
 if ($totalRows_1) {
$str_sql_category1 = "SELECT * FROM categori WHERE auto_id = ".$select4;
$result_category1 = mysql_query($str_sql_category1, $connect_db) or die(mysql_error()); 
$row_category1 = mysql_fetch_assoc($result_category1);
 } else {
$str_option = "category = ".$select4;
 }上面出错的SQL语句,在phpmyadmin里运行,可以运行通过....请问哪里错了?
请详细一些.
谢谢~

解决方案 »

  1.   

      试试 $str_sql_category1 = "SELECT * FROM categori WHERE auto_id = '".$select4."'";
      

  2.   

    $str_sql_category1 = "SELECT * FROM categori WHERE auto_id = '$select4' ";
      

  3.   

    试试 $str_sql_category1 = "SELECT * FROM categori WHERE auto_id = '".$select4."'";
     
    这么写以后提示:select4:34
    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 'SELECT * FROM categori WHERE auto_id = '34'' at line 1
      

  4.   

    直接这样写呢
    $str_sql_category1 = "SELECT * FROM categori WHERE auto_id = $select4";
      

  5.   

    $str_sql_category1 = "SELECT * FROM categori WHERE auto_id =34";  //直接写个数字呢?
    执行一下看有错吗?
      

  6.   

    问题解决了,
    $row_mn4_category1111 = mysql_fetch_array($result_mn4_category1);
    改成变上面的量名以后,就可以了.真是无语了.