Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

No reason for warning ...supplied argument...

Status
Not open for further replies.

webdev007

Programmer
Sep 9, 2005
168
Why do I get a warning when it all goes fine
After the script excerpt are a bunch of inserts or updates and rating math
all are ok.
If I echo the query and paste it in phpMyadmin
I get the expected results
so where is my problem?

existing in the DB are the values id and phone
in my "while" I use those to perform a comparison
with values passed either via POST or SESSION
those values are named $id_check and $phone_check
do you see anything wrong?
Again I get the warning but the job is done!

Warning: mysql_result(): supplied argument is not a valid MySQL result resource

Code:
$conn=db_connect();
$query = "select phone, id from my_table where id !='$id' AND phone='$phone' "; echo"$query";
$result = mysql_query($query) ;

// search to match new with existing
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i <$num)
{
$id_check= mysql_result($result,$i,"id");
$phone_check= mysql_result($result,$i,"phone");
 
try adding some debugging code
Code:
$result = mysql_query($query) or die(mysql_error());
 
I had it before and rem it for it was and is still not showing any info
thanks
 
I think your last loop is trying to look for a resource that does not exist. If the query returns 3 rows, your num_rows will return 3, however your loop will go get four (0,1,2,3). The fourth will not be there and so it will error out. The first three will be completed correctly, so all will appear to be working ok. I suggest you lower the $num for 1 before you loop through it.
 
the reason why you are getting the error you are, is because either you are not conneting to the server, selecting the database or querying the table properly. querying the contents of mysql_error() at each stage will throw light on the problem
 
Thanks both I will in depth check all steps

Last NEWS:
Well, I did a quick change as per Vragabond
moving it to 1 did it :) great idea!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top