Saved X
Google login
SignUp with Email
X

How to catch mysql error in php

theindreshverma ( Added  Sep 09, 11:49 am )
Login

mysql_error — Returns the text of the error message from previous MySQL operation

<?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";
?>

Sourcecode Tags

More Sourcecodes

More Sourcecodes