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. Quote 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 Quote 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)) Quote 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)) Quote 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. Quote 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. Quote 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. Quote 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. Quote 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. Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.