php执行mysql语句输出报语法错误 很急,谢谢解答
YouhaveanerrorinyourSQLsyntax;checkthemanualthatcorrespondstoyourMySQLserverversionfo...
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 'f飞,f ,飞飞, 方法,烦烦烦)' at line 1 执行php代码输出页面
、//下面是php执行文件
<?php
$cfg_dbhost = 'localhost';
$cfg_dbname = 'tianshi';
$cfg_dbuser = 'root';
$cfg_dbpwd = '123456';
$cfg_dbprefix = 'tianshi_';
$cfg_db_language = 'utf8';
$id = $_POST['id'];
$username = $_POST['username'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$hangye = $_POST['h'];
$num = $_POST['num'];
// print_r($name);
echo $username;
echo $phone;
echo $email;
echo $hangye;
echo $num;
// print_r($array);
echo "<pre/>";
$con = @mysql_connect("localhost","root","123456") or die('数据库连接失败');
mysql_set_charset('utf8');
mysql_select_db("tianshi");
$sql = "insert into ts_test(id,phone,email,hangye,num,username) values($id,$phone,$email,$hangye,$num,$username)";
// $result = mysql_query($sql,$con);
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
var_dump($result);
mysql_close($con);
?>
那里写错了。 展开
、//下面是php执行文件
<?php
$cfg_dbhost = 'localhost';
$cfg_dbname = 'tianshi';
$cfg_dbuser = 'root';
$cfg_dbpwd = '123456';
$cfg_dbprefix = 'tianshi_';
$cfg_db_language = 'utf8';
$id = $_POST['id'];
$username = $_POST['username'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$hangye = $_POST['h'];
$num = $_POST['num'];
// print_r($name);
echo $username;
echo $phone;
echo $email;
echo $hangye;
echo $num;
// print_r($array);
echo "<pre/>";
$con = @mysql_connect("localhost","root","123456") or die('数据库连接失败');
mysql_set_charset('utf8');
mysql_select_db("tianshi");
$sql = "insert into ts_test(id,phone,email,hangye,num,username) values($id,$phone,$email,$hangye,$num,$username)";
// $result = mysql_query($sql,$con);
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
var_dump($result);
mysql_close($con);
?>
那里写错了。 展开
1个回答
推荐于2016-10-04
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询