Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How To Get MySQL Statement Execution Errors
How To Get MySQL Statement Execution Errors? - MySQL FAQs - PHP Connections and Query Execution
✍: FYIcenter.com
When you execute a MySQL statement with mysql_query(), and the statement failed, mysql_query() will return the Boolean value FALSE. This is good enough to tell that there is something wrong with that statement. But if you want to know more about the cause of the failure, you can use mysql_errno() and mysql_error() get the error number and error message. The tutorial exercise below shows you an improved version of the previous PHP script:
<?php $con = mysql_connect('localhost:8888', 'guest', 'pub'); $sql = 'CREATE DATABASE fyicenter'; if (mysql_query($sql, $con)) { print("Database fyicenter created.\n"); } else { print("Database creation failed with error:\n"); print(mysql_errno($con).": ".mysql_error($con)."\n"); } mysql_close($con); ?>
If you run this script, you will get something like this:
Database creation failed with error: 1044: Access denied for user 'guest'@'%' to database 'fyicenter'
2007-05-10, 4650👍, 0💬
Popular Posts:
Why does malloc(0) return valid memory address? What's the use? malloc(0) does not return a non-NULL...
Once I have developed the COM wrapper do I have to still register the COM in registry? Yes.
What Articles Have You Read about JUnit? There are a number of JUnit articles that you should read: ...
What Is URI? URI (Uniform Resource Identifier) is a superset of URL. URI provides a simple and exten...
Give me the example of SRS and FRS SRS :- Software Requirement Specification BRS :- Basic Requiremen...