<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("lobbymen_hireus", $con);
$query = mysql_query("INSERT INTO hireus (name, cname, email, telephone)
VALUES (ashfaq, muhm, ashfaq@, 1234566)");
if (!mysql_query($query,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($con);
?>
答案 0 :(得分:3)
您需要正确格式化字符串以进行插入:
$query = mysql_query("INSERT INTO hireus (name, cname, email, telephone)
VALUES ('ashfaq', 'muhm', 'ashfaq@', '1234566')");
但这只是这段代码的冰山一角......
答案 1 :(得分:2)
嗯,首先,您需要在值周围加上引号,因为它们是字符串。您还在查询查询,因此您需要将$ query更改为:
$query = "INSERT INTO hireus (name, cname, email, telephone)
VALUES ('ashfaq', 'muhm', 'ashfaq@', '1234566')";
答案 2 :(得分:1)
您的查询有问题,应该是这样的:
$query = mysql_query("INSERT INTO hireus (name, cname, email, telephone) VALUES ('ashfaq', 'muhm', 'ashfaq@', '1234566')");
答案 3 :(得分:0)
您正在执行两次查询(第二次查询结果是查询,因此返回false),并且您忘记了值周围的引号。它应该是
$query = "INSERT INTO hireus (name, cname, email, telephone) VALUES ('ashfaq', 'muhm', 'ashfaq@', '1234566')";
if (!mysql_query($query,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";