在我的php脚本中找不到错误。有人能指给我看吗
我在web服务器上编写了一个php脚本,将值插入表表3。用于获取值的变量是用户名和图像username包含varchar类型数据,image包含文本类型数据。我需要将其插入我的表表3。表3有两列分别为varchar类型和text类型的username和imagename 当我试图通过输入值来运行上述脚本时,会显示一个错误,如下所示: 错误:您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以了解第1行“1”附近使用的正确语法 我不明白错误是什么,我被困在这里知道错误。有人能帮我把错误清除掉吗。我是php的新手,对php知之甚少。所以需要任何人的帮助。。。请帮帮我。我的php脚本如下所示:在我的php脚本中找不到错误。有人能指给我看吗,php,mysql,sql,database,mysqli,Php,Mysql,Sql,Database,Mysqli,我在web服务器上编写了一个php脚本,将值插入表表3。用于获取值的变量是用户名和图像username包含varchar类型数据,image包含文本类型数据。我需要将其插入我的表表3。表3有两列分别为varchar类型和text类型的username和imagename 当我试图通过输入值来运行上述脚本时,会显示一个错误,如下所示: 错误:您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以了解第1行“1”附近使用的正确语法 我不明白错误是什么,我被困在这里知道错误。有人能帮我把错误清
<?php
$con=mysqli_connect("localhost","username","password","db_name");
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$username = $_POST['username'];
$image = $_POST['image'];
$result = mysqli_query($con,"INSERT INTO table3 (username,imagename) VALUES ('$username','$image')");
if (!mysqli_query($con,$result))
{
die('Error: ' . mysqli_error($con));
}
else
echo "1 record added";
mysqli_close($con);
?>
您应该编写以下内容
$result = mysqli_query($con,"INSERT INTO table3 (username,imagename) VALUES ('$username','$image')");
if (!$result)
{
die('Error: ' . mysqli_error($con));
}
if (!$result)
{
die('Error: ' . mysqli_error());
}
你应该写些类似的东西
$result = mysqli_query($con,"INSERT INTO table3 (username,imagename) VALUES ('$username','$image')");
if (!$result)
{
die('Error: ' . mysqli_error($con));
}
if (!$result)
{
die('Error: ' . mysqli_error());
}
你应该写些类似的东西
$result = mysqli_query($con,"INSERT INTO table3 (username,imagename) VALUES ('$username','$image')");
if (!$result)
{
die('Error: ' . mysqli_error($con));
}
if (!$result)
{
die('Error: ' . mysqli_error());
}
你应该写些类似的东西
$result = mysqli_query($con,"INSERT INTO table3 (username,imagename) VALUES ('$username','$image')");
if (!$result)
{
die('Error: ' . mysqli_error($con));
}
if (!$result)
{
die('Error: ' . mysqli_error());
}
情况应该是这样的
$result = mysqli_query($con,"INSERT INTO table3 (username,imagename) VALUES ('$username','$image')");
if (!$result)
{
die('Error: ' . mysqli_error($con));
}
if (!$result)
{
die('Error: ' . mysqli_error());
}
情况应该是这样的
$result = mysqli_query($con,"INSERT INTO table3 (username,imagename) VALUES ('$username','$image')");
if (!$result)
{
die('Error: ' . mysqli_error($con));
}
if (!$result)
{
die('Error: ' . mysqli_error());
}
情况应该是这样的
$result = mysqli_query($con,"INSERT INTO table3 (username,imagename) VALUES ('$username','$image')");
if (!$result)
{
die('Error: ' . mysqli_error($con));
}
if (!$result)
{
die('Error: ' . mysqli_error());
}
情况应该是这样的
$result = mysqli_query($con,"INSERT INTO table3 (username,imagename) VALUES ('$username','$image')");
if (!$result)
{
die('Error: ' . mysqli_error($con));
}
if (!$result)
{
die('Error: ' . mysqli_error());
}
1) **您的SQL语法有错误;**表示您的查询有错误。您的查询似乎还可以,但错误可能来自您的post数据。您需要为post数据创建一个链接
2) 您已经执行了两次查询
试着这样做:
$username = mysqli_real_escape_string($con, $_POST['username']);
$image = mysqli_real_escape_string($con,$_POST['image']);
$result = mysqli_query($con,"INSERT INTO table3 (username,imagename) VALUES ('$username','$image')");
if (!$result)
{
die('Error: ' . mysqli_error($con));
}
else
echo "1 record added";
mysqli_close($con);
1) **您的SQL语法有错误;**表示您的查询有错误。您的查询似乎还可以,但错误可能来自您的post数据。您需要为post数据创建一个链接
2) 您已经执行了两次查询
试着这样做:
$username = mysqli_real_escape_string($con, $_POST['username']);
$image = mysqli_real_escape_string($con,$_POST['image']);
$result = mysqli_query($con,"INSERT INTO table3 (username,imagename) VALUES ('$username','$image')");
if (!$result)
{
die('Error: ' . mysqli_error($con));
}
else
echo "1 record added";
mysqli_close($con);
1) **您的SQL语法有错误;**表示您的查询有错误。您的查询似乎还可以,但错误可能来自您的post数据。您需要为post数据创建一个链接
2) 您已经执行了两次查询
试着这样做:
$username = mysqli_real_escape_string($con, $_POST['username']);
$image = mysqli_real_escape_string($con,$_POST['image']);
$result = mysqli_query($con,"INSERT INTO table3 (username,imagename) VALUES ('$username','$image')");
if (!$result)
{
die('Error: ' . mysqli_error($con));
}
else
echo "1 record added";
mysqli_close($con);
1) **您的SQL语法有错误;**表示您的查询有错误。您的查询似乎还可以,但错误可能来自您的post数据。您需要为post数据创建一个链接
2) 您已经执行了两次查询
试着这样做:
$username = mysqli_real_escape_string($con, $_POST['username']);
$image = mysqli_real_escape_string($con,$_POST['image']);
$result = mysqli_query($con,"INSERT INTO table3 (username,imagename) VALUES ('$username','$image')");
if (!$result)
{
die('Error: ' . mysqli_error($con));
}
else
echo "1 record added";
mysqli_close($con);
SQL请求(INSERT)在第9行发送,结果被捕获在$result
中。
$result
包含受上一个请求影响的行数(1)
然后再次调用mysqli_查询方法,将值$result
作为SQL请求:“1”不是有效的SQL请求。您的SQL请求(INSERT)在第9行发送,结果被捕获在$result
中。
$result
包含受上一个请求影响的行数(1)
然后再次调用mysqli_查询方法,将值$result
作为SQL请求:“1”不是有效的SQL请求。您的SQL请求(INSERT)在第9行发送,结果被捕获在$result
中。
$result
包含受上一个请求影响的行数(1)
然后再次调用mysqli_查询方法,将值$result
作为SQL请求:“1”不是有效的SQL请求。您的SQL请求(INSERT)在第9行发送,结果被捕获在$result
中。
$result
包含受上一个请求影响的行数(1)
然后再次调用mysqli_查询方法,将值$result
作为SQL请求:“1”不是有效的SQL请求。您已经执行了两次查询mysqli\u查询($con,$result)
此处$result
不是查询字符串。您已经执行了两次查询mysqli\u查询($con,$result)
此处$result
不是查询字符串。您已经执行了两次查询mysqli\u查询($con,$result)
此处$result
不是查询字符串。您已经执行了两次查询mysqli\u查询($con,$result)
此处$result
不是查询字符串。