NYCPHP Meetup

NYPHP.org

[nycphp-talk] MySQL Monitor V PHP & MySQL

PaulCheung paulcheung at tiscali.co.uk
Sat Sep 22 11:52:09 EDT 2007


Hello Michael,

Sorry,  I was trying to make the statement more readable by putting the
WHERE and AND at the end of the line rather than at the beginning and
unconsciously mixed in to the email COBOL, where its' SELECT statement does
use WHEN, my apologies. Here is the actual statement used which didn't work
and it still does not, for me at least.

$sql = "SELECT access_code
        FROM authorised_users
        WHERE user_id = '$userid'
        AND user_password = '$password'
        AND account = '$account'";

This is what I was expecting (from MySQL Monitor) and got

mysql> use test_db;
Database changed
mysql> select access_code from authorised_users where user_id = 'Nancy' and
use_password = 'qwerty' and account = '48572998';
+-------------+
| access_code |
+-------------+
| 11966552    |
+-------------+
1 row in set (0.00 sec)

This is what I got from (PHP MySQL)

sql = SELECT access_code FROM authorised_users WHERE user_id = 'Nancy' AND
user_password = 'qwerty' AND account = '48572998';
Welcome - your log-in succeeded!
accesscode = access_code
$accesscode = access_code

I was expecting '11966552'

Paul



----- Original Message ----- 
From: "Michael Southwell" <michael.southwell at nyphp.com>
To: <talk at lists.nyphp.org>
Sent: Saturday, September 22, 2007 12:41 AM
Subject: Re: [nycphp-talk] MySQL Monitor V PHP & MySQL


> Quoting PaulCheung <paulcheung at tiscali.co.uk>:
>
>> I have researched, checked and tried everything I can think of and
>> still cannot get it to work.
>
>> SELECT access_code FROM authorised_users WHEN
>
> I am not familiar with WHEN but that could be my own ignorance
>
>> $rs = @mysql_select_db( "test_db", $conn )
>>  or die( "Could not select database" );
>>
>> $rs = @mysql_select_db( "test_db", $conn ) or die( "Could not select
>> database" );
>
> This line is doubled but that is not your problem.
>
>>
>> $sql = "SELECT access_code
>>        FROM authorised_users
>>        user_id = '$userid' AND
>
> This is the reason that you are getting different results:  you left  out
> the WHEN that you had above (unless this is not an accurate
> representation of your code); whether WHEN is a legitimate keyword is  a
> different issue.
>
> -- 
> Michael Southwell
> Vice President, Education
> NYPHP TRAINING http://nyphp.com/training/indepth
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php



More information about the talk mailing list