RE: [PHP] Is there a way to check if a record with an Arbitrary Primary Keyexists in a MySQL DB?
| From: | Jennifer Goodie | Date: | Wed, 07 May 2003 23:25:50 +0000 |
| Subject: | RE: [PHP] Is there a way to check if a record with an Arbitrary Primary Keyexists in a MySQL DB? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-146759@lists.php.net to get a copy of this message | ||
You could do mysql_num_rows() on the result identifier to see how many rows
were returned, or instead of selecting * you could select count(*) and use
mysql_result() to see what the output is. I would suggest reading up on the
mysql extension and its functions.
http://www.php.net/manual/en/ref.mysql.php
The return from mysql_query does not contain the result set, it contains a
resource identifier (http://www.php.net/manual/en/function.mysql-query.php)
which is why you got that output from print_r().
> -----Original Message-----
> From: Daniel R. Anderson [mailto:dan@mathjunkies.com]
> Sent: Wednesday, May 07, 2003 4:13 PM
> To: php-general@lists.php.net
> Subject: [PHP] Is there a way to check if a record with an Arbitrary
> Primary Keyexists in a MySQL DB?
>
>
> I am creating a PHP script to add data to a mySQL database. Is there
> any way to check if a record with a primary key exists that would return
> TRUE or FALSE? I tried to print_r a SELECT * FROM that should return an
> empty set and all I got was: "Resource ID #3".
>
> Thanks,
>
> -Dan Anderson
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>