PHP往数据库写入数据,怎么输入都失败为什么? 10
HTML:<fontsize="5"face="楷体"color="black"><center>发布新闻系统</center></font><formname="art...
HTML: <font size="5" face="楷体" color="black"><center>发布新闻系统</center></font> <form name="article" method="get" action="new_insert.php" style="margin:5px 500px;"> 新闻编码:<input type="text" name="new_id"/><br/> 标题:<input type="text" name="title"/><br/> 发布人:<input type="text" name="issuer"/><br/> 类别:<select name="sort" width="10px"> <option value="health">健康 <option value="humor">幽默 <option value="science">科学<select><br/> 内容:<textarea cols=30 rows=5 name="content"></textarea><br/><br/> <input type="submit" value="发布新闻"/> </form>PHP:<?phpini_set("error_reporting","E_ALL & ~E_NOTICE");$new_id=trim($new_id);$title=trim($title);$issuer=trim($issuer);$content=trim($content);$sort=trim($sort);/*if($new_id==""||$title==""||$issuer==""||$content==""||$sort==""){ echo "标题及发布人、发布内容等均不能为空!";}*/$link=mysqli_connect("localhost","root","123456")or ("数据库服务器连接失败!<br/>");mysqli_select_db("aa",$link) or ("数据库连接失败<>");mysqli_query("set names 'gbk'");$sql="select new_id from news where new_id='$new_id'";$result=mysqli_query($sql,$link);$row=mysqli_fetch_array($result);if ($row) { echo"该新闻已存在!"; } $sql="insert into news) values('$new_id','$title','$content','2015-08-22','$issuer','$sort')";if(mysqli_query($sql,$link)) echo"发布成功!"; else echo"发布失败!";?>
展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询