Jump to content

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result reso


Monk3h

Recommended Posts

Dosnt seem to like the second Line That i post (2nd line is line 4 in my Script) Can anyone tell me whats wrong with it.. I have a feeling its the +1, if so could some one please sugest another way of doing this?

 

$mytribe = mysql_fetch_array(mysql_query("select * from tribes where id=$stat[tribe]"));
$devcount = mysql_fetch_array(mysql_query("select * from dev where id=$mytribe[devcount]+1[tribe]"));

Link to comment
Share on other sites

Separating out your functions and adding or die statements would be a good idea:

 

<?php
$devcount = mysql_fetch_array(mysql_query("select * from dev where id=$mytribe[devcount]+1[tribe]"));
//becomes:
$sql = "select * from dev where id=$mytribe[devcount]+1[tribe]";
$result = mysql_query($sql) or die(mysql_error().'<br />On the query:'.$sql);
$devcount = mysql_fetch_array($result);
?>

 

You'll then get told what the error is. Though i can see it - '+1[tribe]' doesn't make a lot of sense. What are you trying to do?

Link to comment
Share on other sites

I'm not a pro at this by any means but yeah the +1 looks to be the problem.  I think what you're going to need to do is make a variable like this before that line:

 

$id = ($mytribe[devcount]+1) . [tribe]

 

and then in the query do....

 

from dev where id=$id

 

 

I'm probably wrong here but I think the problem is basically you're doing PHP math inside of your query where it can't be performed, that all has to be done beforehand.

 

Again I want to stress that I am very new to PHP so if someone else responds they probably know way more about it then I do.

Link to comment
Share on other sites

You will get an error if your sql statement is wrong. it is not the fetching of the array that errors out it is your statement itself. That is why you should break up your variables so you can troubleshoot

 

$sql = "select * from tribes where id='".$stat['tribe']."'";
$result = mysql_query($sql) or die(mysql_error());
$mytribe = mysql_fetch_array($result);

 

If you put mysql_error() it would have told you there was an error in your statement. Also not sure what the next thing is but figure out your number before trying to filter it.

 

the [tribe] thing confuses me.

 

$newid = $mytribe['devcount']+1;
$sql2 = "select * from dev where id='$newid'";
$result2 = mysql_query($sql2) or die(mysql_error());
$devcount = mysql_fetch_array($result2);

 

Ray

Link to comment
Share on other sites

Sorry for wasting your Time guys, the problem was the [tribe] Part, I removed that and it works now.. I have no idea why i put that in or What i was thinking.

 

Sorry again and thanks for your Insanely Fast Responses! :P

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.