Oracle 5.0 Reference Manual page 2277

Table of Contents

Advertisement

Example 20.35.
<?php
$link = mysql_connect("localhost", "mysql_user", "mysql_password");
if (!mysql_select_db("nonexistentdb", $link)) {
echo mysql_errno($link) . ": " . mysql_error($link). "\n";
}
mysql_select_db("kossu", $link);
if (!mysql_query("SELECT * FROM nonexistenttable", $link)) {
echo mysql_errno($link) . ": " . mysql_error($link) . "\n";
}
?>
The above example will output something similar to:
1049: Unknown database 'nonexistentdb'
1146: Table 'kossu.nonexistenttable' doesn't exist
See Also
mysql_error
MySQL error codes
20.7.2.5.11.
mysql_error
Copyright 1997-2012 the PHP Documentation Group. [2230]
mysql_error
Returns the text of the error message from previous MySQL operation
Description
string mysql_error(
resource link_identifier
=
=NULL);
Returns the error text from the last MySQL function. Errors coming back from the MySQL database
backend no longer issue warnings. Instead, use
this function only returns the error text from the most recently executed MySQL function (not including
mysql_error
calling another MySQL function.
Parameters
link_identifier
Original MySQL API (Mysql)
example
mysql_errno
Warning
This extension is deprecated as of PHP 5.5.0, and will be removed in the
future. Instead, the
also
MySQL: choosing an API
Alternatives to this function include:
mysqli_error
PDO::errorInfo
and mysql_errno), so if you want to use it, make sure you check the value before
The MySQL connection. If the link identifier is not specified, the
last link opened by
is found, it will try to create one as if
MySQLi
or
PDO_MySQL
guide and
related FAQ
mysql_error
mysql_connect
2257
extension should be used. See
for more information.
to retrieve the error text. Note that
is assumed. If no such link
mysql_connect
was called

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents