Home > Backend Development > PHP Tutorial > 求圣人检查下面的代码错在哪里

求圣人检查下面的代码错在哪里

WBOY
Release: 2016-06-13 11:48:11
Original
878 people have browsed it

求高人检查下面的代码错在哪里。
代码如下,添加后提示添加失败。

<br /><meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> <br /><?php<br />phpinfo();<br />//这是一个信息增、删、改操作处理页面<br /><br />//一、导入配置文件。<br />		require("dbconfig.php");<br />//二、链接MYSQL、并选择数据库。<br />		$link = @mysql_connect(HOST,USER,PASS) or die("数据库链接错误!");<br />		mysql_select_db(DBNAME,$link);<br />//三、根据action的值,来判断所操作,执行对应的代码。<br /> switch ($_GET["action"]){<br />	 case "add": //执行添加<br />	 //1、获取要添加的信息,并补充其它信息<br />	 $title = $_POST["title"];<br />	 $keywords = $_POST["keywords"];<br />	 $author = $_POST["author"];<br />	 $content = $_POST["content"];<br />	 $addtime = time();<br />	 //2、添加信息过过滤(省略)<br />	 //3、拼装添加SQL语句,并执行添加操作<br />		$sql = "insert into news valuse(null,'{$title}','{$keywords}','{$author}','{$addtime}','{$content}')";<br />//      echo $sql;  //这一步打印正常。<br />		mysql_query($sql,$link);<br />	 //4、判断是否添加成功,<br />	 	$id = mysql_insert_id($link);//判断刚刚添加的信息ID值值<br />		echo $id;<br />		break;<br />		if ($id>0){<br />			echo"<h3>添加成功</H3>";<br />			}else{<br />			echo"<h3>添加失败</H3>";<br />				}<br />	 break;<br />	 <br />	 case "del": //执行删除<br />	 <br />	 break;<br />	 <br />	 case "update": //执行修改<br />	 <br />	 break;<br />	 <br />	 }<br />//四、关闭数据库<br />mysql_close($link);<br />?><br />
Copy after login



------解决方案--------------------
第一段:insert?into?news?valuse
第二段:insert into news values
一个是valuse另一个是valuse

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template