RE: [PHP] Help needed about queries with MySQL, thanks.

2002-08-18 Thread Craig Vincent

> I have a MySQL database (called "sessions") with a auto-increment
> INT field called "sessionID". I try to check if there is already
> a record in this database with a given sessionID, which is called
> $sessionID in PHP. I use this query, which must be wrong (but I
> cannot find out why !!!) :
>
>SELECT * FROM sessions WHERE sessionID = $sessionID

Although this may or may not help depending on your code (please post it if
you still haven't found a solution...it's the best way for us to help.

Try

SELECT * FROM sessions WHERE sessionID = '$sessionID'

Although if $sessionID contains an integer (which I assume is would) the
quotes aren't needed, you never know. Some OSes are quirky.

Also you may want to add an

echo mysql_error();

line after your initial mysql_query to see if perhaps there's a problem with
PHP communicating with MySQL.

Sincerely,

Craig Vincent


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Help needed about queries with MySQL, thanks.

2002-08-18 Thread Jason Wong

On Sunday 18 August 2002 17:59, Jean-Marc Godart wrote:
> Thanks for your suggestion ... Yes, I tried to print $sessionID (using
> echo()) and I get the right value (the one I am looking for) ... Though the
> query does not work. Any other idea ??? Thanks again !

Please post your code so we can have a look.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
Awright, which one of you hid my PENIS ENVY?
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Help needed about queries with MySQL, thanks.

2002-08-18 Thread Jean-Marc Godart

Thanks for your suggestion ... Yes, I tried to print $sessionID (using
echo()) and I get the right value (the one I am looking for) ... Though the
query does not work. Any other idea ??? Thanks again !

Jean-Marc

- Original Message -
From: "Jason Wong" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, August 18, 2002 11:53 AM
Subject: Re: [PHP] Help needed about queries with MySQL, thanks.


> On Sunday 18 August 2002 17:45, Jean-Marc Godart wrote:
>
> > I have a MySQL database (called "sessions") with a auto-increment INT
field
> > called "sessionID". I try to check if there is already a record in this
> > database with a given sessionID, which is called $sessionID in PHP. I
use
> > this query, which must be wrong (but I cannot find out why !!!) :
> >
> >SELECT * FROM sessions WHERE sessionID = $sessionID
> >
> > Even though there is already a record with the right sessionID, my
program
> > does not find it (I always get 0 when using mysql_num_rows() after the
> > query). Though, if I replace "$sessionID" by, for example 4, then that
> > works and it says there is already a record with that ID.
> >
> > I guess the problem comes from comparing two different kinds of
variables,
> > but I can't fix it ... Could anyone please help ? By advance, thank you
!!!
>
> Have you tried printing out $sessionID to see whether it contains what you
> think it contains?
>
> --
> Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
>
> /*
> Under capitalism, man exploits man.  Under communism, it's just the
opposite.
> -- J.K. Galbraith
> */
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Help needed about queries with MySQL, thanks.

2002-08-18 Thread Jason Wong

On Sunday 18 August 2002 17:45, Jean-Marc Godart wrote:

> I have a MySQL database (called "sessions") with a auto-increment INT field
> called "sessionID". I try to check if there is already a record in this
> database with a given sessionID, which is called $sessionID in PHP. I use
> this query, which must be wrong (but I cannot find out why !!!) :
>
>SELECT * FROM sessions WHERE sessionID = $sessionID
>
> Even though there is already a record with the right sessionID, my program
> does not find it (I always get 0 when using mysql_num_rows() after the
> query). Though, if I replace "$sessionID" by, for example 4, then that
> works and it says there is already a record with that ID.
>
> I guess the problem comes from comparing two different kinds of variables,
> but I can't fix it ... Could anyone please help ? By advance, thank you !!!

Have you tried printing out $sessionID to see whether it contains what you 
think it contains?

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
Under capitalism, man exploits man.  Under communism, it's just the opposite.
-- J.K. Galbraith
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php