You have an error in your SQL syntax; check the manual that corresponds to your MySQL server。。

来源:百度知道 编辑:UC知道 时间:2024/05/15 14:15:38
运行一个程序时来出现这样的问题:

连接数据库成功
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'age=ee,regdate=323-00-00' at line 1

我的代码是:
<?php

//连接数据库
$link_id=mysql_connect("localhost","root","123456") or die("连接失败");

if($link_id)
{
echo "连接数据库成功";
echo "<br>";
//选择数据库
mysql_select_db("my_test") or die(mysql_error());

if(!$_GET['id'])
{
//显示用户列表
$sql="select *from userinfo";
$result=mysql_query($sql);

echo "<table border='1'>
<tr>
<td>编号</td>
<td>用户名称</td>
<td>性别</td>
<td>年龄</td>
<td>注册时间</td>
<td>操作&

你打印出来看看,如果有字符串的字段的话,最好加''试试,$sql="update userinfo set usename='$usename',gender='$gender',age='$age',regdate='$regdate' where id=$id";
这类的,你试试看吧

应该就是楼上说的''""“”这些的问题。挨个试一下。