这是代码:
<html>
<body>
<?php
$con = mysql_connect("localhost","moviek5q_arka","******");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$pizza = "Age
Anger
Architecture
Art
Beauty
Birthday
Business
Car
Change
Computers
Dad
Dating
Death
Design
Diet
Dreams
Education
Environmental
Equality
Experience
Faith
Family
Finance
Fitness
Food
Forgiveness
Friendship
Funny
Gardening
Government
Graduation
Happiness
Health
History
Home
Humor
Imagination
Inspirational
Intelligence
Leadership
Legal
Life
Love
Marriage
Medical
Men
Mom
Money
Motivational
Movies
Music
Nature
Parenting
Patriotism
Peace
Pet
Poetry
Politics
Power
Religion
Science
Society
Sports
Success
Technology
Teen
Time
Travel
Trust
War
Wedding
Wisdom
Women
Work
";
$pieces = explode("\n", $pizza);
$i=0;
$a=mysql_select_db("moviek5q_Quote", $con);
if(!$a) echo"Error";
for($i=8;$i<75;$i++) {
$sql=mysql_query("INSERT INTO moviek5q_Quote.Categories (Key, Name)
VALUES
(NULL,'$pieces[$i]')");
if(!$sql) {die('Could not connect: ' . mysql_error());}
}
mysql_close($con);
echo "done";
?>
</body>
</html>
但是运行脚本会出现错误:
无法连接:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的 'Key, Name) VALUES (NULL,'Change')' 附近使用正确的语法