$dbc=mysql_connect('127.0.0.1', 'root', '1234','aliendatabase')
or die('Failed!');
$query = "INSERT INTO alien_abduction(first_name, last_name, when_it_happened, how_long, " .
"how_many, alien_description, what_they_did, fang_spotted, other, email) " .
"VALUES ('$first_name', '$last_name', '$when_it_happened',
'$how_long', '$how_many', " .
"'$alien_description', '$what_they_did', '$fang_spotted', '$other',
'$email')";
$result=mysql_query($query)
or die("Failed to upload!!!!");
mysql_close($dbc);
此代码无法执行$ result line(因此输出无法上传!!!!)但它能够建立连接。我已经交叉检查了表的列名和变量,看起来很好。
MySQL版本5.7
答案 0 :(得分:0)
请检查列的数据类型并执行以下操作以查找错误:
$结果= mysql_query($查询) 或者死(mysql_error($ dbc));
答案 1 :(得分:-2)
问题出在你的报价方式上。 由于单引号不会用于保存变量。所以在单引号中,它们只是字符串,而不是变量。
如果你想用$variable
替换为value,那么用单引号重写整个查询,如下所示
$query = 'INSERT INTO alien_abduction(first_name, last_name, when_it_happened, how_long, how_many, alien_description, what_they_did, fang_spotted, other, email) '.
' VALUES (' ".$first_name." ', ' ".$last_name . " ', ' ". $when_it_happened . " ', ' " .$how_long . " ', ' " . $how_many . " ', " . " " . $alien_description . " ', ' " . $what_they_did . " ', ' " . $fang_spotted . " ', ' " . $other . " ', ' " . $email . " ')' ;
我希望能解决这个问题。