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 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥50 汇编语言除法溢出问题
  • ¥65 C++实现删除N个数据列表共有的元素
  • ¥15 Visual Studio问题
  • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波