Originally posted by ejwf
I was exepcting the output
4
which is the ClientId for the company I am using in the test, but instead I got
Resource id #5
I have no idea what this is - do you?
The function mysql_query() returns a resource. You can't print_r() it , it's a not a printable data type.
There's three things I see that I don't think are the problem, but .... you never know:
$Client = $POST[client];
//The constant 'client' is probably not defined, so that should be this, instead:
$Client = $POST['client'];
//Yes it usually works without quotes - but syntactically, it's incorrect.
//Double quotes in SQL variable tests are slightly safer, and in my experience cause no problems.
//Also adding a database name (important), and backticks on table names (not so important), avoids some problems.
$query = 'SELECT ClientId FROM dbName.`tblClient` WHERE CoName = "' . $Client . '"';
Come to think of it, I made the assumption that you've already made a connection to the database with mysql_connect(), and subsequently selected a database with mysql_select_db(). Have you?