dongni8969 2014-12-12 14:17
浏览 39
已采纳

Logcat显示Parse错误:语法错误,第2行C:\ wamp \ www \ signup.php中出现意外':'。使用php和mysql登录和注册表单

I am a novice in php field here, currently I am working on a simple login and registration form for testing. But I get some errors, need some help from you all..tq

Below here is some of my code.. please help, thanks in advance

loginform.php:

<html>
<form action="signup.php"method="post">
    Username=<input type="text" name="n"></br>
    Password=<input type="password" name="p"></br>
    id<input type="text"name="id"></br>
    <input type="submit">
</form>
</html>

signup.php:

<?php
    $conn = mysql_connect("localhost","root","");
    $db   = mysql_select_db("whatevershit_login","$conn");  
?>

<?php

    $user = $_POST['n'];
    $pass = $_POST['p'];
    $id = $_POST['id'];
    $sql= "INSERT TO whatevershit_login value (".$id",'"$user"'','"$pass"')";

    $query=mysql_query($sql);

    #INSERT TO whatevershit_login value (
    #   1,
    #   'ken',
    #   'ken')
?>

and this is the error I get, but I still don't know why.. because I check all the syntax already.. maybe I could be wrong, but I don't know, so I hope can get you all help.. thank you..

Parse error: syntax error, unexpected ':' in C:\wamp\www\signup.php on line 2

  • 写回答

1条回答 默认 最新

  • dongyang0005 2014-12-12 14:34
    关注

    One syntax error I can see is with the line.

    $sql= "INSERT TO whatevershit_login value (".$id",'"$user"'','"$pass"')";
    

    To correctly perform string concatenation it needs to read as follows.

    $sql= "INSERT INTO whatevershit_login VALUES (".$id.",'".$user."','".$pass."')";
    

    With regards the error message I am assuming that you are getting the following.

    Parse error: syntax error, unexpected ':' in C:\wamp\www\signup.php on line 2.
    

    This means that there is a colon character somewhere on line 2 of the file called signup.php. I'm guessing that the colon is at the end of the line and is a typo. In which case you just need to change it for a semi-colon ;

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化