Table of Contents

Syntax

string mysql_error([resource $res])

(PHP 4, PHP 5)

$res The database connection resource that we want to use.
RETURNS A human-readable error message for the last MySQL error generated.

What it Does

Creates a human-readable error message for the last MySQL error generated. Use this to debug database query errors in your page. If the optional parameter $res is left out, the function will use the last database resource opened by the script.

Example

// open the mysql resource
$res = mysql_connect($server, $user, $pass);
 
// insert a single row into tblState
mysql_query('INSERT * INTO tblState (\'California\')', $res);
 
// return the number of rows
$rows = mysql_affected_rows($res);
 
mysql_error.txt · Last modified: 2008/04/18 14:01 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki