Re: Error with in_use() from Beginning PHP4 book.
| From: | Paul Burney | Date: | Sat, 25 Aug 2001 21:57:48 +0000 |
| Subject: | Re: Error with in_use() from Beginning PHP4 book. | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-11830@lists.php.net to get a copy of this message | ||
on 8/25/01 12:11 PM, sam at sam@netfuze.com wrote:
>
>
> Hi Wrox guys and all,
>
> Can anyone help me out on this??
>
> I've been using this code for quite some time now. I got it from the
> "Beginning PHP4 by Choi, Kent, Lea, Prasad, and Ullman". All those times, I
> don't get any errors UNTIL tonight! :(
>
> I am now getting this error message:
> "Warning: Supplied argument is not a valid MySQL result resource in
> c:\nusphere\apache\htdocs\domainfolder\register.php on line 17"
>
> function in_use($username){
> global $user_tablename;
>
> $query = "SELECT username FROM $dbuser WHERE username = '$username'";
> $result = mysql_query($query);
> if(!mysql_num_rows($result)) return 0; // this is the line 17.
> else return 1;
> }
Is that the code for the function exactly? If so, where is $dbuser set? If
it's set outside the function, you need to make it a global
global $user_tablename,$dbuser;
> Does this have anything to do with updated MySQL parser? I am now using
> MySQL version 3.23.36.
Possibly if the version of PHP that you are using was linked to old versions
of the MySQL headers. You may need to recompile PHP.
Sincerely,
Paul Burney
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Paul Burney
Webmaster && Open Source Developer
UCLA -> GSE&IS -> ETU
(310) 825-8365
<webmaster@gseis.ucla.edu>
<http://www.gseis.ucla.edu/>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++