Reply to Re: not a valid MySQL result resource

Your name:

Reply:


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

Ron Eggler schrieb:
> 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();
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
WHY?

> $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++;
> }
> }
mysql_close();
> [/code]
> I don't see why $result shouldn't be valid anymore, can anyone help?
> Thanks lots!
> Ron
Why do you close the connection and then still using it?

Best
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

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