Reply to Re: not a valid MySQL result resource

Your name:

Reply:


Posted by Olaf Schinkel on 12/19/07 11:45

ZeldorBlat schrieb:
> On Dec 17, 3:58 pm, Ron Eggler <NORE...@example.com> wrote:
>> Hi,
>>
>> I get some weird MySql error and don't see why, the error i get is:
>> "Warning: mysql_result(): supplied argument is not a valid MySQL result
>> resource in /opt/lampp/htdocs/sessionid.php on line 25" when i'm trying to
>> either INSERT or UPDATE depending on if the row is existing already. My
>> code is pasted below: (line 25 is the line "$DBemail=mysql_result($result
>> $i,"email");")
>> [code]
>> if ($intime && $email) // the client want to a seminar so we need to
>> decrese the avail space nby one.
>> {
>> $query="SELECT email from video";
>> $result=mysql_query($query);
>> $num=mysql_numrows($result); // count rows from column email
>> mysql_close();
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
That....


>> $i=0;
>> while (($i-1)< $num) // check if email already exists in db
>> {
>> $DBemail=mysql_result($result,$i,"email");
>> if ($DBemail==$email)
>> $query="UPDATE video SET intime='".$intime."' WHERE email='"
>> $email."'";
>> else
>> $query="INSERT INTO video (`email`,`intime`) VALUES ('"
>> $email."','".$intime."')";
>> $result=mysql_query($query);
>> if ($result==FALSE)
>> echo "Error in inserting email and intime into table!<br />";
>> $i++;
>> }
>> }
>> [/code]
>> I don't see why $result shouldn't be valid anymore, can anyone help?
>> Thanks lots!
>> Ron
>
> From the manual:
>
> "For other type of SQL statements, UPDATE, DELETE, DROP, etc,
> mysql_query() returns TRUE on success or FALSE on error."
>
> When you insert or update you're assigning the return value of
> mysql_query (which is boolean true or false) to $result. The second
> time through your while loop, $result doesn't contain a result
> resource anymore -- but you're trying to use mysql_result() on it
> anyway.
Read the OP!
Invalid resource.
He closes the sql and is wondering, why he has no more sql connections :-)


Olaf

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация