dsgs8208 2015-11-29 17:45
浏览 74

解析错误:语法错误,意外'VALUES'(T_STRING)[重复]

This question already has an answer here:

I am trying to create my first database. I mainly used this tutorial to have my database up and connected, however, I am having some problems inserting the data from the form into the database. I know the db is connected as I can retrieve the data data back from the db to the php but not in other way round.

I tried searching, but it seems that the problem is too unique for me to generalize from the past issues already solved.

I have this error whenever I finish up the forum:

Parse error: syntax error, unexpected 'VALUES' (T_STRING) in D:\xampp\htdocs\softwarefirm\create.php on line 20

The code for the create file is:

<?php
    include 'include/connection.php';

    $name = $_POST['inputFirstName'];
    $email = $_POST['inputEmail'];
    $pnum = $_POST['inputPhoneNumber'];
    $hdate = $_POST['HireDate'];
    $jtitle = $_POST['JobTitle'];
    $salary = $_POST['Salary'];
    $manid = $_POST['ManagerID'];
    $depid = $_POST['DepartmentID'];

    if(!$_POST['submit']) {

        echo "please fill out the form";
        header('Location: index.php');
    } else {

        mysql_query("INSERT INTO employee (`EID`, `FirstName`, `Email`, `PhoneNumber`, `HireDate`, `JobTitle`, `Salary`, `ManagerID`, `DepartmentID`")
            VALUES(NULL, '$name', '$email', '$pnum', '$hdate', '$jtitle', '$salary', '$manid','$depid')") or die(mysql_error());
echo "User has been added";
header ('Location: index.php');
    }

    ?>
</div>
  • 写回答

1条回答 默认 最新

  • doudi5524 2015-11-29 17:49
    关注

    Here's the error:

    mysql_query("INSERT INTO employee (`EID`, `FirstName`, `Email`, `PhoneNumber`, `HireDate`, `JobTitle`, `Salary`, `ManagerID`, `DepartmentID`")
            VALUES(NULL, '$name', '$email', '$pnum', '$hdate', '$jtitle', '$salary', '$manid','$depid')")
    

    Remove the second double-quotes from the mysql_query-line. The line should end with:

    `DepartmentID`)
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度