pontiac007 Posted March 20, 2007 Share Posted March 20, 2007 I keep getting this: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in ....... code: while($row = mysql_fetch_array($result, MYSQL_ASSOC)) what can i do? i still new in php. Link to comment https://forums.phpfreaks.com/topic/43541-solved-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-result-reso/ Share on other sites More sharing options...
genericnumber1 Posted March 20, 2007 Share Posted March 20, 2007 show us all your code Link to comment https://forums.phpfreaks.com/topic/43541-solved-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-result-reso/#findComment-211443 Share on other sites More sharing options...
papaface Posted March 20, 2007 Share Posted March 20, 2007 Should be: while($row = mysql_fetch_assoc($result)) Link to comment https://forums.phpfreaks.com/topic/43541-solved-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-result-reso/#findComment-211459 Share on other sites More sharing options...
genericnumber1 Posted March 20, 2007 Share Posted March 20, 2007 while($row = mysql_fetch_assoc($result)) is the same thing as while($row = mysql_fetch_array($result, MYSQL_ASSOC)) Link to comment https://forums.phpfreaks.com/topic/43541-solved-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-result-reso/#findComment-211465 Share on other sites More sharing options...
per1os Posted March 20, 2007 Share Posted March 20, 2007 We need to see the query and where $result is being set. Link to comment https://forums.phpfreaks.com/topic/43541-solved-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-result-reso/#findComment-211469 Share on other sites More sharing options...
pontiac007 Posted March 21, 2007 Author Share Posted March 21, 2007 here is the codes: $query = "SELECT acadstaff.idstaff, acadstaff.staffname, student.idstud FROM acadstaff, student WHERE idstud=$_SESSION[idstud]"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $staffname= $row['staffname']; ?> <?php echo "{$row['staffname']} <br>";?></a> <? } Iive tried changing array to assoc before but it doesn't work. Link to comment https://forums.phpfreaks.com/topic/43541-solved-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-result-reso/#findComment-211690 Share on other sites More sharing options...
per1os Posted March 21, 2007 Share Posted March 21, 2007 <?php $query = "SELECT acadstaff.idstaff, acadstaff.staffname, student.idstud FROM acadstaff, student WHERE idstud=$_SESSION[idstud]"; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { $staffname= $row['acadstaff.staffname']; echo $row['acadstaff.staffname']; } ?> Should work. Link to comment https://forums.phpfreaks.com/topic/43541-solved-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-result-reso/#findComment-211693 Share on other sites More sharing options...
pontiac007 Posted March 21, 2007 Author Share Posted March 21, 2007 It doesn't work. I've tried to change SELECT statement but it still didn't work out. Link to comment https://forums.phpfreaks.com/topic/43541-solved-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-result-reso/#findComment-211706 Share on other sites More sharing options...
per1os Posted March 21, 2007 Share Posted March 21, 2007 <?php $query = "SELECT acadstaff.idstaff, acadstaff.staffname, student.idstud FROM acadstaff, student WHERE idstud=$_SESSION[idstud]"; $result = mysql_query($query) or DIE(mysql_error()); while($row = mysql_fetch_array($result)) { $staffname= $row['acadstaff.staffname']; echo $row['acadstaff.staffname']; } ?> See if there is an error in the query. Link to comment https://forums.phpfreaks.com/topic/43541-solved-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-result-reso/#findComment-211708 Share on other sites More sharing options...
pontiac007 Posted March 21, 2007 Author Share Posted March 21, 2007 Thanx guys!! i've found my mistake. Link to comment https://forums.phpfreaks.com/topic/43541-solved-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-result-reso/#findComment-211764 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.