Monk3h Posted April 8, 2008 Share Posted April 8, 2008 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]")); Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted April 8, 2008 Share Posted April 8, 2008 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? Quote Link to comment Share on other sites More sharing options...
Roq Posted April 8, 2008 Share Posted April 8, 2008 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. Quote Link to comment Share on other sites More sharing options...
craygo Posted April 8, 2008 Share Posted April 8, 2008 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 Quote Link to comment Share on other sites More sharing options...
Monk3h Posted April 8, 2008 Author Share Posted April 8, 2008 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! Quote Link to comment 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.