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

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

WBOY
Release: 2016-06-23 13:10:05
Original
1009 people have browsed it

代码奉上:

	$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');
Copy after login

刚学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键上面那个字符。

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

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