Page 1 of 1
Warning: mysql_fetch_assoc(): 4
Posted: Mon Oct 03, 2005 12:48 pm
by ATH0
Hi to all !.
This is my first posting to this forum ( drums

).
I have db (mySql ) with 3 records.
When i run query to make list of all those records ( where id = 10 ) i get one record corectly displayed but instead second record i get error message:
Warning: mysql_fetch_assoc(): 4
Why?
p.s. Everything else is working fine ( connections, selects and so on )..
ATH0
Posted: Mon Oct 03, 2005 1:30 pm
by hawleyjr
Please post your code. Are you connecting to the database?
Posted: Tue Oct 04, 2005 2:32 am
by ATH0
Code: Select all
<?php
mysql_select_db($database_dbConn, $dbConn);
$query_dbNew = "SELECT images.image, images.desc FROM images WHERE images.group='100'";
$dbNew = mysql_query($query_dbNew, $dbConn) or die(mysql_error());
$row_dbNew = mysql_fetch_assoc($dbNew);
$totalRows_dbNew = mysql_num_rows($dbNew);
mysql_free_result($dbNew);
?>
<!------------------------------------------------->
<div align="center">
<table border="1" cellpadding="1" cellspacing="1">
<?php do { ?>
<tr>
<td><font size="1" face="Verdana, Arial, Helvetica, sans-serif">
<?php echo $row_dbNew['image']; ?></font></td>
<td><font size="1" face="Verdana, Arial, Helvetica, sans-serif">
<?php echo $row_dbNew['desc']; ?></font></td>
<td><font size="1" face="Verdana, Arial, Helvetica, sans-serif"> </font></td>
</tr>
<?php } while
($row_dbNew = mysql_fetch_assoc($dbNew));
?>
</table>
----------------
I am connected to db and i can work with db....
2.) Table creation:
Maybe dump question... Since i have 3 records (2 of them should mach the query ), is it possible that there is a problem with "dinamic table creation" , becuse i allways get one record displayed(regardless how many records are in DB)...
Posted: Tue Oct 04, 2005 2:53 am
by ruchit
the problem is here
you are free-ing up the recordset aftering fetching the first row of the data... then you are trying to fetch the remaining rows in the do-while loop.
IMHO, you shold improve your coding style... try to study few codes posted on the forum or take some reference from a book.
[SOLVED]
Posted: Tue Oct 04, 2005 3:24 am
by ATH0
:--)).
Well, it looks like i have to stop drinking. ;--)
Thank you for your replay and solved question !
ATH0