checking for mysql_pconnect error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

checking for mysql_pconnect error

Post by pelegk2 »

how can i check,using which function whats execlly the error that occur on mysql_pconnect function?
thnaks in advance
peleg
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

http://php.net/mysql_error

Eg:

Code: Select all

$db = mysql_pconnect('...', '...', '...') or die(mysql_error());
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

ow and ithoguth that mysql_error() is only good to use with mysql_query() :):)
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Nope ;) mysql_error() can be used on almost every mysql_* function (and should be used where possible).
I even use it when dining out with friends, it can even attract members of the opposite sex :o
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

hahahahahahahahahaha
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

Mark - but when you have a SELECT query that returns 0 rows it fires the error.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

uh.. not that I've ever seen Grim. The mysql functions return false when there's an error.

The only times you shouldn't really use mysql_error() is with mysql_num_rows() and the fetch_* triplets, because those return 0/false for special reasons..
Post Reply