EasyPHPScripts.com      Free Open Source PHP Scripts and Code Snippet Library

 +Menu
+   Site News
+   Main Pages
+   Other Downloads
 +PHP
+ Arrays (9)
+ Directory And Files (7)
+ Image (3)
+ LDAP (3)
+ MySQL (11)
+ Basic MySQL Example
+ Database Information
+ Error Checking
+ Fetch Associative Array
+ Last Insert ID
+ Number of Rows
+ Record Paging
+ SQL Dump to Database
+ Select Examples
+ Table and Field Information
+ Various Information
+ Other (11)
+ Regular Expressions (3)
+ String Manipulation (13)
+ Time and Date (6)
 +Snippet Options
+   Printer Friendly
 +Library Options
+   View Other Library
 +General Options
+   Log in
Description for Snippet: MySQL / Error Checking
  Check for errors using mysql_errno() and mysql_error()
 
Syntax for: Error Checking

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
<?php
    mysql_connect
("localhost""mysql_user""mysql_password");

    
mysql_select_db("nonexistentdb");
    echo 
mysql_errno() . ": " mysql_error(). "n";

    
mysql_select_db("kossu");
    
mysql_query("SELECT * FROM nonexistenttable");
    echo 
mysql_errno() . ": " mysql_error() . "n";
?>
 


 
Powered by: PHP & centOS