好的,那么我想建立的是:您登录的网站(稍后我会这样做)。有一个表单可以让你提交新闻报道,然后进入MySQL数据库。然后在iPhone的表视图中显示(稍后会出现)。正如我提到的,我得到一个"错误查询数据库"。我试图修复它,但我是新的MySQL和PHP,所以我不知道还能做什么。我在主服务器(WAMP)上设置了这个。
我report.html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Football Central News Report Submission Page</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<h1>Football Central News Report Submission Page</h1>
<h2>Sumbit your football news report here</h2>
<h3>CHECK FOR MISTAKES !!!</h3>
<form method="post" action="report.php">
<label for="title">Title:</label>
<input type="text" name="title" />
<br />
<label for="author">Author:</label>
<input type="text" name="author" />
<br />
<label for="subtitle">Subtitle:</label>
<input type="text" name="subtitle" />
<br />
<label for="body">Body:</label>
<textarea name="body"></textarea>
<br />
<label for="image">Image:</label>
<input type="file" id="image" name="image" />
<br />
<input type="submit" value="Submit your news report" name="submit" />
</form>
</body>
</html>
我report.php :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Football Central News Report Submission Page</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<h1>Football Central News Report Submission Page (Confirmation)</h1>
<?php
$title = $_POST['title'];
$author = $_POST['author'];
$subtitle = $_POST['subtitle'];
$body = $_POST['body'];
$image = $_POST['image'];
$dbc = mysqli_connect('localhost', 'root', 'xxxxxx', 'news_reports')
or die('Error connecting to database server.');
$query = "INSERT INTO news_reports (title, author, subtitle, body) " .
"VALUES ('$title', '$author', '$subtitle', '$body', '$image')";
$result = mysqli_query($dbc, $query)
or die('Error querying database.');
mysqli_close($dbc);
?>
<p>
-Thanks for submitting the form.<br />
-Your news report has been submitted to the database and should appear in the app shorty.
</p>
</body>
</html>
AND最后-我的数据库结构(我不能发布截图)字段:Report_id(主键,自动递增)标题作者副标题身体图片
p。年代对于图像/'我遵循"头第一PHP和MySQL",所以它是存储在数据库中的图像名称,而不是图像(我没有把它放入表单,但我不认为这是问题)。
很抱歉,伙计们。《路加福音》
不匹配。您指定了要插入的4列,但定义了5个值。添加缺失的列。
$query = "INSERT INTO news_reports (title, author, subtitle, body) " .
"VALUES ('$title', '$author', '$subtitle', '$body', '$image')"