Re: [PHP] PDO Error
Yes, you're right. It's false This dont't work too. foreach ($dbh->query('SELECT * FROM words') as $row) { echo $row['word'] . ""; } But this works $stmt = $dbh->prepare('select * from words'); $stmt->execute(); $rows = $stmt->fetchAll(); echo count($rows) . ""; "Marek Kilimajer" <[EMAIL PROTECTED]> escreveu na mensagem news:[EMAIL PROTECTED] > Holografix wrote: >> print_r($stmt) prints nothing. print($stmt) print nothing too. >> >> I checked errorCode() and it prints . > > Then it seems $stmt is false. var_dump() is more verbose about it. > >> >> >> "Marek Kilimajer" <[EMAIL PROTECTED]> escreveu na mensagem >> news:[EMAIL PROTECTED] >> >>>Holografix wrote: >>> Hi Marek It's print_r($row), not print_r($stmt) ;) >>> >>>That's what I'm asking - If you put print_r($stmt) in that line, what >>>does it print? >>> >>> "Marek Kilimajer" <[EMAIL PROTECTED]> escreveu na mensagem news:[EMAIL PROTECTED] >Holografix wrote: > > >>Hi. When using this example from >>http://netevil.org/talks/index.php?t=pdo&s=20, the site of pdo's >>author I have this error: >> >>Fatal error: Call to a member function fetchAll() on a non-object in >>/www/home/testes/pdo_my1.php on line 17 >> >> >>$dbh = new PDO('mysql:host=localhost;dbname=dbtest', 'user', 'pass'); >>$stmt = $dbh->query("SELECT * FROM foo"); > >what does print_r($stmt); print here? > > > >>$rows = $stmt->fetchAll(); >>$count = count($rows); >>foreach ($rows as $row) { >> print_r($row); >>} >>$stmt = null; >> >>Wht's wrong with the example? >> >>Greetings >>holografix >> >> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO Error
Holografix wrote: print_r($stmt) prints nothing. print($stmt) print nothing too. I checked errorCode() and it prints . Then it seems $stmt is false. var_dump() is more verbose about it. "Marek Kilimajer" <[EMAIL PROTECTED]> escreveu na mensagem news:[EMAIL PROTECTED] Holografix wrote: Hi Marek It's print_r($row), not print_r($stmt) ;) That's what I'm asking - If you put print_r($stmt) in that line, what does it print? "Marek Kilimajer" <[EMAIL PROTECTED]> escreveu na mensagem news:[EMAIL PROTECTED] Holografix wrote: Hi. When using this example from http://netevil.org/talks/index.php?t=pdo&s=20, the site of pdo's author I have this error: Fatal error: Call to a member function fetchAll() on a non-object in /www/home/testes/pdo_my1.php on line 17 $dbh = new PDO('mysql:host=localhost;dbname=dbtest', 'user', 'pass'); $stmt = $dbh->query("SELECT * FROM foo"); what does print_r($stmt); print here? $rows = $stmt->fetchAll(); $count = count($rows); foreach ($rows as $row) { print_r($row); } $stmt = null; Wht's wrong with the example? Greetings holografix -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO Error
print_r($stmt) prints nothing. print($stmt) print nothing too. I checked errorCode() and it prints . "Marek Kilimajer" <[EMAIL PROTECTED]> escreveu na mensagem news:[EMAIL PROTECTED] > Holografix wrote: >> Hi Marek >> >> It's print_r($row), not print_r($stmt) ;) > > That's what I'm asking - If you put print_r($stmt) in that line, what does > it print? > >> >> >> >> "Marek Kilimajer" <[EMAIL PROTECTED]> escreveu na mensagem >> news:[EMAIL PROTECTED] >> >>>Holografix wrote: >>> Hi. When using this example from http://netevil.org/talks/index.php?t=pdo&s=20, the site of pdo's author I have this error: Fatal error: Call to a member function fetchAll() on a non-object in /www/home/testes/pdo_my1.php on line 17 $dbh = new PDO('mysql:host=localhost;dbname=dbtest', 'user', 'pass'); $stmt = $dbh->query("SELECT * FROM foo"); >>> >>>what does print_r($stmt); print here? >>> >>> $rows = $stmt->fetchAll(); $count = count($rows); foreach ($rows as $row) { print_r($row); } $stmt = null; Wht's wrong with the example? Greetings holografix >> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO Error
Holografix wrote: Hi Marek It's print_r($row), not print_r($stmt) ;) That's what I'm asking - If you put print_r($stmt) in that line, what does it print? "Marek Kilimajer" <[EMAIL PROTECTED]> escreveu na mensagem news:[EMAIL PROTECTED] Holografix wrote: Hi. When using this example from http://netevil.org/talks/index.php?t=pdo&s=20, the site of pdo's author I have this error: Fatal error: Call to a member function fetchAll() on a non-object in /www/home/testes/pdo_my1.php on line 17 $dbh = new PDO('mysql:host=localhost;dbname=dbtest', 'user', 'pass'); $stmt = $dbh->query("SELECT * FROM foo"); what does print_r($stmt); print here? $rows = $stmt->fetchAll(); $count = count($rows); foreach ($rows as $row) { print_r($row); } $stmt = null; Wht's wrong with the example? Greetings holografix -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO Error
Hi Georgi >From php manual: PDO::query Executes an SQL statement, returning a result set as a PDOStatement object () object PDO::query ( string statement ) So, $stmt shoul be an object. Thanks four your answers. I will post a more detailed message in php-db where this problem belongs. My fault posted it in php-general. Greetings "Georgi Ivanov" <[EMAIL PROTECTED]> escreveu na mensagem news:[EMAIL PROTECTED] >> Hi. When using this example from >> http://netevil.org/talks/index.php?t=pdo&s=20, the site of pdo's author I >> have this error: >> >> Fatal error: Call to a member function fetchAll() on a non-object in >> /www/home/testes/pdo_my1.php on line 17 >> >> > Object creation : >> $dbh = new PDO('mysql:host=localhost;dbname=dbtest', 'user', 'pass'); >> $stmt = $dbh->query("SELECT * FROM foo"); > Here I think $stmt is NOT an object. > $stmp should be RESOURCE or boolean value most likely. > So it should be $rows=$dbh->fetchAll(); >> $rows = $stmt->fetchAll(); >> $count = count($rows); >> foreach ($rows as $row) { >> print_r($row); >> } >> $stmt = null; >> >> Wht's wrong with the example? >> >> Greetings >> holografix > > -- > Regards > Georgi Ivanov -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO Error
Hi Marek It's print_r($row), not print_r($stmt) ;) "Marek Kilimajer" <[EMAIL PROTECTED]> escreveu na mensagem news:[EMAIL PROTECTED] > Holografix wrote: >> Hi. When using this example from >> http://netevil.org/talks/index.php?t=pdo&s=20, the site of pdo's author I >> have this error: >> >> Fatal error: Call to a member function fetchAll() on a non-object in >> /www/home/testes/pdo_my1.php on line 17 >> >> >> $dbh = new PDO('mysql:host=localhost;dbname=dbtest', 'user', 'pass'); >> $stmt = $dbh->query("SELECT * FROM foo"); > > what does print_r($stmt); print here? > >> $rows = $stmt->fetchAll(); >> $count = count($rows); >> foreach ($rows as $row) { >> print_r($row); >> } >> $stmt = null; >> >> Wht's wrong with the example? >> >> Greetings >> holografix >> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO Error
> Hi. When using this example from > http://netevil.org/talks/index.php?t=pdo&s=20, the site of pdo's author I > have this error: > > Fatal error: Call to a member function fetchAll() on a non-object in > /www/home/testes/pdo_my1.php on line 17 > > Object creation : > $dbh = new PDO('mysql:host=localhost;dbname=dbtest', 'user', 'pass'); > $stmt = $dbh->query("SELECT * FROM foo"); Here I think $stmt is NOT an object. $stmp should be RESOURCE or boolean value most likely. So it should be $rows=$dbh->fetchAll(); > $rows = $stmt->fetchAll(); > $count = count($rows); > foreach ($rows as $row) { > print_r($row); > } > $stmt = null; > > Wht's wrong with the example? > > Greetings > holografix -- Regards Georgi Ivanov -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO Error
Holografix wrote: Hi. When using this example from http://netevil.org/talks/index.php?t=pdo&s=20, the site of pdo's author I have this error: Fatal error: Call to a member function fetchAll() on a non-object in /www/home/testes/pdo_my1.php on line 17 $dbh = new PDO('mysql:host=localhost;dbname=dbtest', 'user', 'pass'); $stmt = $dbh->query("SELECT * FROM foo"); what does print_r($stmt); print here? $rows = $stmt->fetchAll(); $count = count($rows); foreach ($rows as $row) { print_r($row); } $stmt = null; Wht's wrong with the example? Greetings holografix -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PDO Error
Hi. When using this example from http://netevil.org/talks/index.php?t=pdo&s=20, the site of pdo's author I have this error: Fatal error: Call to a member function fetchAll() on a non-object in /www/home/testes/pdo_my1.php on line 17 $dbh = new PDO('mysql:host=localhost;dbname=dbtest', 'user', 'pass'); $stmt = $dbh->query("SELECT * FROM foo"); $rows = $stmt->fetchAll(); $count = count($rows); foreach ($rows as $row) { print_r($row); } $stmt = null; Wht's wrong with the example? Greetings holografix -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php