PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
michaelpeerman
Forum Newbie
Posts: 2 Joined: Sun Oct 04, 2009 12:26 am
Post
by michaelpeerman » Sun Oct 04, 2009 12:29 am
This is what i get
Code: Select all
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/tsmonkey/public_html/1337board.co.cc/thread.php on line 182
Heres what is on line 182
Code: Select all
for($i=0;$post=mysql_fetch_array($posts);$i++){
Please tell me whats wrong
requinix
Spammer :|
Posts: 6617 Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA
Post
by requinix » Sun Oct 04, 2009 3:12 am
What's wrong is you didn't post the entire chunk of code that deals with whatever it's doing and instead only posted one line.
Griven
Forum Contributor
Posts: 165 Joined: Sat May 09, 2009 8:23 pm
Post
by Griven » Sun Oct 04, 2009 3:43 am
What he posted is fine.
When something is not a valid MySQL resource, that means there's been an error in your query--something's not right.
Check your query again and make sure it's not throwing an error.
requinix
Spammer :|
Posts: 6617 Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA
Post
by requinix » Sun Oct 04, 2009 4:57 am
Griven wrote: What he posted is fine.
When something is not a valid MySQL resource, that means there's been an error in your query--something's not right.
Check your query again and make sure it's not throwing an error.
Could also be that the query was never executed. Wouldn't be the first time I've seen someone try
Code: Select all
$posts="SELECT * FROM table";
for($i=0;$post=mysql_fetch_array($posts);$i++){
Thus I asked for more code: to see the problem rather than just guess at the solution.
Griven
Forum Contributor
Posts: 165 Joined: Sat May 09, 2009 8:23 pm
Post
by Griven » Sun Oct 04, 2009 5:07 am
tasairis wrote: Thus I asked for more code: to see the problem rather than just guess at the solution.
... but I like guessing games.
He's right--make sure you're actually executing the query as well.
lipun4u
Forum Commoner
Posts: 82 Joined: Wed Jul 01, 2009 3:35 am
Location: Mumbai
Contact:
Post
by lipun4u » Sun Oct 04, 2009 7:31 am
Code: Select all
$posts="SELECT * FROM table";
$result = mysql_query($sql);
while ($data = mysql_fetch_row($result)) {
hope..above code will help u
jmaker
Forum Newbie
Posts: 16 Joined: Tue May 21, 2002 11:13 pm
Post
by jmaker » Sun Oct 04, 2009 9:06 am
Why do you have your sql statement assigned to $posts, and then the variable $sql being passed to the function? Try this.
Code: Select all
$sql = "SELECT * FROM table";
$result = mysql_query($sql);
while ($data = mysql_fetch_row($result)) {
lipun4u
Forum Commoner
Posts: 82 Joined: Wed Jul 01, 2009 3:35 am
Location: Mumbai
Contact:
Post
by lipun4u » Sun Oct 04, 2009 9:16 am
that was silly mistake buddy...