在DW写的PHP代码<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<?php
mysql_connect('localhost','root','778692');
 mysql_query("set names gbk");
mysql_select_db('test');
INSERT INTO `test`.`votes` (`id` ,
`sport` ,
`ballot` 
)
VALUES (
'4', '乒乓球', '0'

?>
</body>
</html>
为什么总是报错:
Parse error: syntax error, unexpected 'INTO' (T_STRING) in C:\xampp\htdocs\toupiaopiao\result.php on line 15

解决方案 »

  1.   

    哥们这个代码不对啊, insert into 是个sql语句,怎么可以直接那样写呢?
    $sql="insert into ... ";
    mysql_query($Sql,$conn); //conn是链接的对象 $conn=mysql_connect('localhost','root','778692');sql语句正确性 你可以直接先在数据库中判断
      

  2.   

    $sql =<<< SQLINSERT INTO `test`.`votes` (`id` ,
    `sport` ,
    `ballot`  
    )
    VALUES (
    '4', '乒乓球', '0'
    )  
    SQL;mysql_query($sql);
      

  3.   

    <?php
     
     $sql="insert into votes(sport) values('羽毛球')";
    mysql_query($Sql, $conn=mysql_connect('localhost','root','778692')); //conn是链接的对象 $conn=mysql_connect('localhost','root','778692');mysql_close();
    ?>
    </body>
    改成这样吗??
      

  4.   


    <?php
        mysql_connect("localhost", "mysql_user", "mysql_password") or
            die("Could not connect: " . mysql_error());
        mysql_select_db("mydb");    mysql_query("INSERT INTO mytable (product) values ('kossu')");
        printf ("Last inserted record has id %d\n", mysql_insert_id());
    ?> 
      

  5.   

    上面的几位都是正确的方法啊,PHP里面不能直接写这个sql语句啊