Warning: mysql_fetch_assoc(): showing in PHP 5.2 but not 4

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
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

Warning: mysql_fetch_assoc(): showing in PHP 5.2 but not 4

Post by jonnyfortis »

hello
I am building a shopping cart site that was on 1&1 and it was using PHP4 but now i have moved the cart integration and needed to move it up and am now running php 5.2 but an error has now come up within the content of and image that is has a Tom Muck repeat region in it

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in/homepages/6/d132436789/htdocs/beta/product-list.php on line 169


<?php
$None_endRow = 0;
}
} while ($row_None = mysql_fetch_assoc($None));
if($None_endRow != 0) {
while ($None_endRow < $None_columns) {
echo("<td> </td>");
$None_endRow++;
}
echo("</tr>");
}?>

the error line being
if($None_endRow != 0) {

the page still functions but how do i clear this error?


thanks in advance
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: Warning: mysql_fetch_assoc(): showing in PHP 5.2 but not

Post by twinedev »

It doesn't sound like a difference in the versions of PHP, but more of the settings for PHP. On old server it was most likely set to hide warnings by default, and the new server shows them (which, IMO it is best to have them on and report everything when you are developing the script, otherwise like in your case, things don't pop up till you get to a different environment)

Provide proper checking that the query actually returned data before trying to use it:

Code: Select all

$None = mysql_query($SQL_Statement);
if ($None && mysql_num_rows($None)>0) {

  // Your code to use data
	
  mysql_free_result($None);
}
else {
  // Optional Code to display when there are no results
} 
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

Re: Warning: mysql_fetch_assoc(): showing in PHP 5.2 but not

Post by jonnyfortis »

ok. for now i have just added

error_reporting(0);

this isnt good because thats not the point but the site is live

i will try your advise in my testing area
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

Re: Warning: mysql_fetch_assoc(): showing in PHP 5.2 but not

Post by jonnyfortis »

the problem was i hadnt defind the recordset in the query

Code: Select all

            <?php
 $rsProductData_endRow = 0;
  }
} while ($row_rsProductData = mysql_fetch_assoc($rsProductData));
if($rsProductData_endRow != 0) {
while ($rsProductData_endRow < $rsProductData_columns) {
    echo("<td>&nbsp;</td>");
    $rsProductData_endRow++;
}
echo("</tr>");
}?>
Post Reply