satre Posted April 9, 2010 Share Posted April 9, 2010 Hi, I hope someone can help me with this... I'm trying to get data from a table and work with it row by row. Here's a snippet of the code: $query = "SELECT program, nickname, city, state, director, directoremail, title, coordinator, coordinatoremail FROM contact"; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { echo "Program :{$row['program']} <br>" . "{$row['city']}, {$row['state']} <br>" . "Nickname : {$row['nickname']} <br>" . "Director : Dr. {$row['message']} <br>" . "Coordinator : {$row['title']} {$row['message']} <br><br>"; $myemail = "[email protected]"; $director = $row['director']; $coordinatortitle = $row['title']; $coordinator = $row['coordinator']; $programnickname = $row['nickname']; $program = $row['program']; $directoremail = $row['directoremail']; $coordinatoremail = $row['coordinatoremail']; And here's the error I get: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/content... on line 33 (the closing bracket for the while statement is further down in the code) Thanks for your help! -Satre Quote Link to comment https://forums.phpfreaks.com/topic/198063-supplied-argument-is-not-a-valid-mysql-result-resource/ Share on other sites More sharing options...
spfoonnewb Posted April 9, 2010 Share Posted April 9, 2010 Check you query. $result = mysql_query($query) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/198063-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-1039247 Share on other sites More sharing options...
satre Posted April 9, 2010 Author Share Posted April 9, 2010 Oh, duh. My table name is actually "contacts". Works now. Thanks spfoonnewb! Quote Link to comment https://forums.phpfreaks.com/topic/198063-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-1039258 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.