亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

文章發布系統

?create table article(

? ? -> id int(11) primary key auto_increment default null,

? ? -> title char(100) not null,

? ? -> author char(50) not null,

? ? -> description varchar(255) not null,

? ? -> cotent text not null,

? ? -> dateline int(11)

? ? -> )ENGINE=INNODB DEFAULT CHARSET=utf8;

這是數據表

<!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">
<head>
<meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"?/>
<title>無標題文檔</title>
<style?type="text/css">
body?{
	margin-left:?0px;
	margin-top:?0px;
	margin-right:?0px;
	margin-bottom:?0px;
}
</style>
</head>

<body>
<table?width="100%"?height="520"?border="0"?cellpadding="8"?cellspacing="1"?bgcolor="#000000">
??<tr>
????<td?height="89"?colspan="2"?bgcolor="#FFFF99"><strong>后臺管理系統</strong></td>
??</tr>
??<tr>
????<td?width="156"?height="287"?align="left"?valign="top"?bgcolor="#FFFF99"><p><a?href="article.add.php">發布文章</a></p>
????<p><a?href="article.manage.php">管理文章</a></p>??????<a?href="article.add.php"></a></td>
????<td?width="837"?valign="top"?bgcolor="#FFFFFF">
????<form?id="form1"?name="form1"?method="post"?action="article.add.handle.php">
??????<table?width="779"?border="0"?cellpadding="8"?cellspacing="1">
????????<tr>
??????????<td?colspan="2"?align="center">發布文章</td>
??????????</tr>
????????<tr>
??????????<td?width="119">標題</td>
??????????<td?width="625"><label?for="title"></label>
????????????<input?type="text"?name="title"?id="title"?/></td>
????????</tr>
????????<tr>
??????????<td>作者</td>
??????????<td><input?type="text"?name="author"?id="author"?/></td>
????????</tr>
????????<tr>
??????????<td>簡介</td>
??????????<td><label?for="description"></label>
????????????<textarea?name="description"?id="description"?cols="60"?rows="5"></textarea></td>
????????</tr>
????????<tr>
??????????<td>內容</td>
??????????<td><textarea?name="content"?cols="60"?rows="15"?id="content"></textarea></td>
????????</tr>
????????<tr>
??????????<td?colspan="2"?align="right"><input?type="submit"?name="button"?id="button"?value="提交"?/></td>
??????????</tr>
??????</table>
????</form></td>
??</tr>
??<tr>
????<td?colspan="2"?bgcolor="#FFFF99"><strong>版權所有</strong></td>
??</tr>
</table>
</body>
</html>
這是頁面

require_once('../connect.php');

//把傳遞過來的信息入庫,在入庫之前對所有的信息進行校驗。

if(!(isset($_POST['title'])&&(!empty($_POST['title'])))){

echo "<script>alert('標題不能為空');window.location.href='article.add.php';</script>";

}


$title = $_POST['title'];

$author = $_POST['author'];

$description = $_POST['description'];

$content = $_POST['content'];

$dateline = ?time();

$insertsql = "insert into article(title, author, description, content, dateline) values('$title', '$author', '$description', '$content', $dateline)";

?//echo ?$insertsql;

if(mysql_query($insertsql)){

echo "<script>alert('發布文章成功');window.location.href='article.manage.php';</script>";

}else{

echo "<script>alert('發布失敗');window.location.href='article.manage.php';</script>";


} ?

?>

? ? 插入數據,

header("Content-type:text/html charset=utf-8");

? ? define('localhost','127.0.0.1');

? ? define('USERNAME', 'root');

? ? define('PASSWORD', '201609');

配置文件

require_once('config.php');

? ?//連庫

? ?if(!($con=mysql_connect(localhost,USERNAME,PASSWORD))){

? ? ? echo ?mysql_error();

? ?}

? ?//選庫

? ?if(mysql_select_db('code')){

? ? ? ?echo ?mysql_error();

? ?}

? ?//字符集

? ?if(mysql_query('set names utf8')){

? ? ? ?echo ?mysql_error();

? ?}

連接庫

但是就是發布失敗

正在回答

2 回答

dateline 的問題,把dateline 刪了就好了

0 回復 有任何疑惑可以回復我~

$insertsql = "insert into article(title, author, description, content, dateline) values('$title', '$author', '$description', '$content', $dateline)"; ?中$dateline少了單引號' ' ????

0 回復 有任何疑惑可以回復我~
#1

慕粉4279450 提問者

加了也一樣
2017-06-23 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
PHP與MySQL關系大揭秘
  • 參與學習       72509    人
  • 解答問題       978    個

讓我們一起走上探秘之旅,找尋php和mysql戀愛的真諦

進入課程

文章發布系統

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號