您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以便在第1行的''附近使用正确的语法

时间:2014-07-11 06:44:07

标签: mysql sql

这是我用来插入表格的查询。

我收到这样的错误

$sql = mysql_query("INSERT INTO userinfo(runnername,runnerdob,runnerage,runnergender,runneraddress,runnercity,runnerstate,runnerpincode,runneremail,runnerpassword,runnermobilenumber,e_name,e_relationship,e_address,e_mobilenumber,height,weight,bloodgroup,category,tshirtsize,accountcreationdate,lastlogin,timestamp,registereduser,ipaddress,status) 
VALUES('$runnername','$dt',$runnerage,'$runnergender','$runneraddress','$runnercity','$runnerstate','$runnerpincode','$runneremail','$epassword','$runnermobilenumber','$e_name','$e_relationship','$e_address','$e_mobilenumber','$height','$weight','$bloodgroup','$category',$tshirtsize,'$accountdate','Y','$t','Y','$ip',1") or die(mysql_error());

这是生成的输出

  

INSERT INTO   用户信息(runnername,runnerdob,runnerage,runnergender,runneraddress,runnercity,runnerstate,runnerpincode,runneremail,runnerpassword,runnermobilenumber,e_name,e_relationship,e_address,e_mobilenumber,身高,体重,bloodgroup,类别,tshirtsize,accountcreationdate,lastlogin,时间戳,registereduser, ip地址,状态)   价值观(' VIDHYA PRAKASH R',' 1985-04-08',29,' M',' 12 DIVINE   RESIDENNCY'' Coimbatore的'' TAMILNADU'' 641035',' vidhyaprakash85@gmail.com',' FU4A31 / GhcmRItAHb97lNtrjRZr + y1yG4arxawG / QES ='' 9944524864''拉金德伦''父亲',' 12   DIVINE RESIDENNCY哥印拜陀TAMILNADU   641035'' 9894773083'' 6'' 6',' A1 +已经'' M&#39 ; 42,' 2014年11月7日   12:11:02'' Y'' 1405060862'' Y'' 127.0.0.1',1)

但我收到错误

  

您的SQL语法有错误;检查手册   对应于您的MySQL服务器版本,以便使用正确的语法   靠近''在第1行

过去两个小时我都在挣扎。

有人请帮帮我吗?

2 个答案:

答案 0 :(得分:0)

问题是在查询结束时,应该避免在单行上编写长插入查询,并且最好在多行中编写,这有助于几乎立即找到问题,或者最好是使用PDO或mysqli的。

您的查询以'Y','$ip',1")结束)

此处查询应如何

$sql = mysql_query(
    "INSERT INTO userinfo
    (
        runnername,
        runnerdob,
        runnerage,
        runnergender,
        runneraddress,
        runnercity,
        runnerstate,
        runnerpincode,
        runneremail,
        runnerpassword,
        runnermobilenumber,
        e_name,
        e_relationship,
        e_address,
        e_mobilenumber,
        height,
        weight,
        bloodgroup,
        category,
        tshirtsize,
        accountcreationdate,
        lastlogin,
        timestamp,
        registereduser,
        ipaddress,
        status
    ) 
    VALUES
    (
        '$runnername',
        '$dt',
        $runnerage,
        '$runnergender',
        '$runneraddress',
        '$runnercity',
        '$runnerstate',
        '$runnerpincode',
        '$runneremail',
        '$epassword',
        '$runnermobilenumber',
        '$e_name',
        '$e_relationship',
        '$e_address',
        '$e_mobilenumber',
        '$height',
        '$weight',
        '$bloodgroup',
        '$category',
        $tshirtsize,
        '$accountdate',
        'Y',
        '$t',
        'Y',
        '$ip',
        1
    )"
) or die(mysql_error());

答案 1 :(得分:0)

你是否在价值陈述的末尾错过了一个小括号?

而不是

'$ip',1")

不应该是

'$ip',1)")