|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
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 |
|
![]() |
| Outils de la discussion | |
|
|