PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > What's this PDO error?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
What's this PDO error?

Réponse
 
LinkBack Outils de la discussion
Vieux 13/06/2008, 14h11   #1
Harris Kosmidhs
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut What's this PDO error?

I 'm having the following statement:

try {
$db = new PDO('mysql:host=localhost;dbname=genderstudies', 'XXX',
'YYY', array(PDO::ATTR_PERSISTENT => true));
$db->exec("SET NAMES UTF8") or die(print_r($db->errorInfo()));
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}

I get an error like this:
Array ( [0] => 00000 ) 1

What is this? I can connect to mysql correctly with the above
username/password and the db exists.

Thanks.
  Réponse avec citation
Vieux 13/06/2008, 14h41   #2
Rik Wasmus
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: What's this PDO error?

Harris Kosmidhs wrote:
> I 'm having the following statement:
>
> try {
> $db = new PDO('mysql:host=localhost;dbname=genderstudies', 'XXX',
> 'YYY', array(PDO::ATTR_PERSISTENT => true));
> $db->exec("SET NAMES UTF8") or die(print_r($db->errorInfo()));
> } catch (PDOException $e) {
> print "Error!: " . $e->getMessage() . "<br/>";
> die();
> }
>
> I get an error like this:
> Array ( [0] => 00000 ) 1



There is no error. From the manual:
"PDO::exec() executes an SQL statement in a single function call,
returning the number of rows affected by the statement. "

No rows affected, returns 0, is cast to false, and you incorrectly
assume 0 is a problem in this context. Use & trust the exceptions, the
return is not of importance to you right now.
--
Rik Wasmus
....spamrun finished
  Réponse avec citation
Vieux 13/06/2008, 14h46   #3
Iván Sánchez Ortega
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: What's this PDO error?

Harris Kosmidhs wrote:

> I get an error like this:
> Array ( [0] => 00000 ) 1
>
> What is this?


It means "no error".

When checking for errors using PDO, compare the $pdo->errorCode() to the
string '00000'; other methods may prove unreliable (such as checking for
the number of rows affected) depending on the situation.

See also:
http://publib.boulder.ibm.com/infoce...e/r0sttmsg.htm

Cheers,
--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

MSN:i_eat_s_p_a_m_for_breakfast@hotmail.com
Jabber:ivansanchez@jabber.org ; ivansanchez@kdetalk.net
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 12h32.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11263 seconds with 11 queries