jkewlo Posted August 6, 2008 Share Posted August 6, 2008 i keep getting Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\Neanix\index.php on line 338 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\Neanix\index.php on line 344 This is the code Note: i have also taken out $rows=mysql_fetch_array($result); and left the while($rows=mysql_fetch_array($result)){ and vise verse. still no luck <?php $sql=mysql_query("SELECT * FROM members WHERE Broadcasting=1" )or die(mysql_error()); $result=mysql_query($sql); $rows=mysql_fetch_array($result); //error here line 338 $showname = $rows['ShowName']; $view = $rows['Views']; $path = $rows['Path']; $username = $rows['Username']; while($rows=mysql_fetch_array($result)){ // error here line 344 if($broadcast = '1'){ echo "Username: ". $username ."<br>"; echo "ShowName: ". $showname ." | Views: ". $view .""; echo "<img src=". $path ." border=0 width=100 height=100 >"; } else { echo "NO SHOWS!"; } } ?> Link to comment https://forums.phpfreaks.com/topic/118522-yet-another-mysql_fetch_array-error/ Share on other sites More sharing options...
DarkWater Posted August 6, 2008 Share Posted August 6, 2008 You call mysql_query() twice, except you do it on the result set the second time...Try: <?php $result=mysql_query("SELECT * FROM members WHERE Broadcasting=1" )or die(mysql_error()); $rows=mysql_fetch_array($result); //error here line 338 $showname = $rows['ShowName']; $view = $rows['Views']; $path = $rows['Path']; $username = $rows['Username']; while($rows=mysql_fetch_array($result)){ // error here line 344 if($broadcast = '1'){ echo "Username: ". $username ."<br>"; echo "ShowName: ". $showname ." | Views: ". $view .""; echo "<img src=". $path ." border=0 width=100 height=100 >"; } else { echo "NO SHOWS!"; } } ?> Link to comment https://forums.phpfreaks.com/topic/118522-yet-another-mysql_fetch_array-error/#findComment-610173 Share on other sites More sharing options...
jkewlo Posted August 6, 2008 Author Share Posted August 6, 2008 ok that worked but its only showing 1 set and i need to show all broadcast online there are 2 right now Link to comment https://forums.phpfreaks.com/topic/118522-yet-another-mysql_fetch_array-error/#findComment-610179 Share on other sites More sharing options...
DarkWater Posted August 6, 2008 Share Posted August 6, 2008 Wow, your code was pretty messed up. I fixed it: <?php $result=mysql_query("SELECT * FROM members WHERE Broadcasting=1" )or die(mysql_error()); $showname = $rows['ShowName']; $view = $rows['Views']; $path = $rows['Path']; $username = $rows['Username']; while($rows=mysql_fetch_array($result)){ $showname = $rows['ShowName']; $view = $rows['Views']; $path = $rows['Path']; $username = $rows['Username']; if($broadcast = '1'){ echo "Username: ". $username ."<br>"; echo "ShowName: ". $showname ." | Views: ". $view .""; echo "<img src=". $path ." border=0 width=100 height=100 >"; } else { echo "NO SHOWS!"; } } ?> And you should honestly try to indent your code more so it's readable. Link to comment https://forums.phpfreaks.com/topic/118522-yet-another-mysql_fetch_array-error/#findComment-610180 Share on other sites More sharing options...
jkewlo Posted August 6, 2008 Author Share Posted August 6, 2008 yeah i can get sloppy lol ahh i should of had it under the while statement. thanks P.S it seems somedays i can do it flawless and other's im just horrible... Link to comment https://forums.phpfreaks.com/topic/118522-yet-another-mysql_fetch_array-error/#findComment-610183 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.