How to use mysql error in PHP

In this article I am going to explain about mysql_error function in PHP.
  • 1485

PHP mysql_error() Function

The PHP mysql_error function returns error message of the last MySQL operation. This function returns a empty string if no error has occurs.

Syntax of mysql_error function

mysql_error(connection)


Parameters in
mysql_error  function

It has only one parameter:
 

Parameter Description
connection It specifies mysql connection.

Example of mysql_error function

<html>

<body>

<?php

$con=@mysql_connect("localhost","MySQLUserName","MYSQLPassword"); // Here we are taken wrong username & password.

if(!$con)

{

die(mysql_error());

}

mysql_close($con);

?>

</body>

</html>


Output:

mysql-error-php.jpg

You may also want to read these related articles :
here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.