burtybob Posted November 2, 2007 Share Posted November 2, 2007 This works as long as i keep it fetching the array with where userid=$c_userid if ($_REQUEST[killname]) { $victim=$_REQUEST[killname]; $killquery=mysql_query("SELECT * FROM members WHERE `userid`=$c_userid") or die(mysql_error()); $killquery=mysql_fetch_array($killquery); $killquery=$killquery[health]; } BUT this DOESNT work if ($_REQUEST[killname]) { $victim=$_REQUEST[killname]; $killquery=mysql_query("SELECT * FROM members WHERE `displayname`=$victim") or die(mysql_error()); $killquery=mysql_fetch_array($killquery); $killquery=$killquery[health]; } Please can anyone inform me as to why the second one wont work when all i do is change the WHERE clause? Is it something im doing rong or is there a genuine reason it tells me faultCode0faultStringWarning:mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/vol4/byethost7.com/b7_568567/lealtatest.22web.net/htdocs/Source code/kill.php on line 161 line 161 is the fetch array bit. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/75818-another-where-clause-problem/ Share on other sites More sharing options...
GingerRobot Posted November 2, 2007 Share Posted November 2, 2007 I assume $victim is a string? You must quote strings in your query. I assume $c_userid is a number, which do not need to be quoted. Try: $killquery=mysql_query("SELECT * FROM members WHERE `displayname`='$victim'") or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/75818-another-where-clause-problem/#findComment-383746 Share on other sites More sharing options...
otuatail Posted November 2, 2007 Share Posted November 2, 2007 Why use the same variable in difrent ways $killquery $killquery=mysql_fetch_array($killquery); $killquery=$killquery[health]; Used as a query used as a result used as a value This can cause confusion later. Quote Link to comment https://forums.phpfreaks.com/topic/75818-another-where-clause-problem/#findComment-383751 Share on other sites More sharing options...
burtybob Posted November 2, 2007 Author Share Posted November 2, 2007 Why use the same variable in difrent ways $killquery $killquery=mysql_fetch_array($killquery); $killquery=$killquery[health]; Used as a query used as a result used as a value This can cause confusion later. I read somewhere on this forum that some other people managed to use this way also it makes sense to me as im using one variable name instead of 4 different ones I tried with the quotes and faultCode0faultStringWarning:mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/vol4/byethost7.com/b7_568567/lealtatest.22web.net/htdocs/Source code/kill.php on line 161 is the result still but the die is not telling me any problems??? Quote Link to comment https://forums.phpfreaks.com/topic/75818-another-where-clause-problem/#findComment-383760 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.