giles
giles

Reputation: 843

Catching MySQL errors

I have a very simple development. I was using Pear DB to error catch a query with something along the lines of

if(DB::isError($create)) die($create->getMessage()); 

I'm wondering if there is something similar in mysql?

Upvotes: 0

Views: 1441

Answers (2)

user909058
user909058

Reputation: 188

$res = mysql_query($query) or die(mysql_error()); 

Upvotes: 0

Janis Lankovskis
Janis Lankovskis

Reputation: 1040

Pear DB is Database Abstraction Layer which works with MySQL.

MySQL:

$res = mysql_query($query);
if(mysql_error()) { die('error!:' . mysql_error() ); }

Upvotes: 1

Related Questions