$tran = "START TRANSACTION;";

    $tran_res = mysql_query($tran);

    $qry_1 = "INSERT INTO docList (doc_ip , doc_country , doc_ref) VALUES ('$ip' , '$country' , '$http_ref');";
    $res_1 = mysql_query($qry_1);
    if(!$res_1)
        die ("qry1 fail " . mysql_error() );

    $ins_id = mysql_insert_id();
    if(!$ins_id)
        die ("ins id fail " . mysql_error() );
    echo "<b>$ins_id</b>";

    $qry_2 = "INSERT INTO docContent (doc_id , cont_date , cont_title , cont_aim , cont_obj , cont_theory , cont_sw , cont_code) VALUES ('$ins_id' , '$dt' , '$title' , '$aim' , '$obj' , '$th' , '$sw' , '$code');";

    $res_2 = mysql_query($qry_2);
    if(!$res_2)
        die("qry2 fail " . mysql_error() );  `

执行上述操作将返回以下错误:
2 qry failYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'login'); if($query->num_rows()>0) return $query->result_array(); } ' at line 1
实际上,$qry_2的执行是失败的,但我对它显示的错误感到困惑(在错误说明中提到的第1行没有这样的代码)。此外,查询($qry_2)在MySql控制台中正确执行。

最佳答案

您还没有发布MySQL服务器接收到的真正查询,但我敢说您没有使用mysql_real_escape_string()将数据注入SQL。
(是否尝试在数据库中插入PHP代码?)

07-24 18:19
查看更多