[nycphp-talk] MySQL Monitor V PHP & MySQL

David Krings ramons at
Sat Sep 22 09:01:55 EDT 2007

Michael Southwell wrote:
> Quoting PaulCheung <paulcheung at>:
>> 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.

AFAIK that WHEN should be a WHERE. Also, the one ID is put in single 
quotes within the query. Better is sth like this if in case IDs are integers

$sql = "SELECT access_code FROM authorised_users WHERE user_id = 
".$userid." AND ....

Not that this is the reason for failure, but I found it somewhat 
difficult to follow the code as there are absolutely no comments. Add 
commentary, at least one comment per two lines of code. That helps to 
understand what you are doing and what the steps are, even for something 
basic like this.


More information about the talk mailing list