Home > Backend Development > PHP Tutorial > mysql_error()函数如果执行的话,每次都显示千篇一律的内容吗解决思路

mysql_error()函数如果执行的话,每次都显示千篇一律的内容吗解决思路

WBOY
Release: 2016-06-13 10:02:06
Original
1047 people have browsed it

mysql_error()函数如果执行的话,每次都显示千篇一律的内容吗
mysql_error()可用在mysql_connect()和mysql_query()执行失败时,那是否不同的情况下,mysql_error()会有不同的文字输出呢?

------解决方案--------------------
$conn=mysql_connect($DBHost,$DBUser,$DBPassword) or die( "数据库连接失败 " . mysql_error());
mysql_select_db($DBDatabase,$conn) or die( "Could not select database ");
$result=mysql_query($sql,$conn) or die( "Query failed : " . mysql_error());

后面的or die可以改成自己的提示信息

------解决方案--------------------
不同的错误显示不同的内容

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