|
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
Navigation:
[Reply to this message]
|