Home >Backend Development >PHP Tutorial >为什么php中insert语句无法插入记录?

为什么php中insert语句无法插入记录?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-23 13:10:051028browse

代码奉上:

	$connec=mysql_connect('localhost','root','root');	if (!$connec){		die('Could not connect: ' . mysql_error());	}	mysql_query("set names 'utf8'");	mysql_select_db('guestbook',$connec);	$sql="insert into yl(title, author, email, content, ip, 'date') values('哈哈', 'php', '123@qq.com', '为什么', '192.1.1.1', '2016-5-6')";	echo $sql;	mysql_query($sql) or die('failed');

刚学php,学到这里按照书上代码写的,为嘛就是成功不了???求教大神


回复讨论(解决方案)

$sql="insert into yl(title, author, email, content, ip, `date`) values('哈哈', 'php', '123@qq.com', '为什么', '192.1.1.1', '2016-5-6')";

date字段的转义符不是单引号,是tab键上面那个字符。

多谢解决了,你说的对,不过我是因为那个表列名没对应

Statement:
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