lawrence_dev
asked on
Need assistance with PDO error: mysql_fetch_array() expects parameter 1 to be resource, object given
I could use some assistance with the following error: Warning: mysql_fetch_array() expects parameter 1 to be resource, object given. ($last = end($row36);) please advise how to adjust for PDO.
$fh = fopen('/thefind.txt', 'w');
$result36 = $conn->query('SELECT * FROM Feeds');
while ($row36 = mysql_fetch_array($result36)) {
$last = end($row36); // Problem here
foreach ($row36 as $item) {
fwrite($fh, $item);
if ($item != $last)
fwrite($fh, "\t");
}
fwrite($fh, "\n");
}
fclose($fh);
ASKER
OK I have an error here:
while ($row36 = $result36->fetch_assoc()) {
Fatal error: Call to undefined method PDOStatement::fetch_assoc( )
Just as a note: I attempted to change to PDO hence the "$result36 = $conn->query('SELECT * FROM Feeds');"
while ($row36 = $result36->fetch_assoc()) {
Fatal error: Call to undefined method PDOStatement::fetch_assoc(
Just as a note: I attempted to change to PDO hence the "$result36 = $conn->query('SELECT * FROM Feeds');"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
QUERY: SELECT * FROM Feeds
FOUND 15,905 ROWS OF DATA
I added the foreach below and got it to work.
while ($row36 = $pdos->fetch(PDO::FETCH_AS SOC))
{
foreach ($row36 as $item) {
fwrite($fh, $item);
if ($item != $last)
fwrite($fh, "\t");
}
fwrite($fh, "\n");
Thanks!
FOUND 15,905 ROWS OF DATA
I added the foreach below and got it to work.
while ($row36 = $pdos->fetch(PDO::FETCH_AS
{
foreach ($row36 as $item) {
fwrite($fh, $item);
if ($item != $last)
fwrite($fh, "\t");
}
fwrite($fh, "\n");
Thanks!
Open in new window