Original MySQL API (
Mysql
)
2258
with no arguments. If no connection is found or established, an
E_WARNING
level error is generated.
Return Values
Returns the error text from the last MySQL function, or
''
(empty string) if no error occurred.
Examples
Example 20.36.
mysql_error
example
<?php
$link = mysql_connect("localhost", "mysql_user", "mysql_password");
mysql_select_db("nonexistentdb", $link);
echo mysql_errno($link) . ": " . mysql_error($link). "\n";
mysql_select_db("kossu", $link);
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_errno
MySQL error codes
20.7.2.5.12.
mysql_escape_string
Copyright 1997-2012 the PHP Documentation Group. [2230]
•
mysql_escape_string
Escapes a string for use in a mysql_query
Warning
This extension is deprecated as of PHP 5.5.0, and will be removed in the
future. Instead, the
MySQLi
or
PDO_MySQL
extension should be used. See
also
MySQL: choosing an API
guide and
related FAQ
for more information.
Alternatives to this function include:
mysqli_escape_string
PDO::quote
Description
string mysql_escape_string(
string unescaped_string);
This function will escape the
unescaped_string
, so that it is safe to place it in a
mysql_query
. This
function is deprecated.
This function is identical to
mysql_real_escape_string
except that
mysql_real_escape_string
takes a connection handler and escapes the string according to the
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...