Home > Backend Development > PHP Tutorial > php 在执行mysql 失败后 怎么写错误提示

php 在执行mysql 失败后 怎么写错误提示

WBOY
Release: 2016-06-23 13:59:33
Original
743 people have browsed it

在写php时 有时因为输入的字段超出 在mysql 设的字段长度 虽然 语句执行正常 但在数据库中没有成功加入 求提示写法


回复讨论(解决方案)

mysql_query($sql) die(mysql_error());

mysql_query($sql) die(mysql_error());
是不是应该是

mysql_query($sql)or die(mysql_error());
Copy after login


die(mysql_error()); 怎么加字 
我写成die(mysql_error()“出错了”)就报错 老是对这个 .. {} 这些掌握不好

die 与 exit 是等价的
函数原型 void exit ( [string status] )
可知参数应该是一个字符串
写作 die(mysql_error() . “出错了”) 就对了

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