Note that $dbPassword
would be a resultset object, not a scalar.
You'd need to "fetch" rows from the resulset.
An example is provided in the documentation http://www.php.net/manual/en/function.mysql-query.php
You also have an issue with PHP string concatenation.
If you did this in two separate steps, you could echo (or printf or vardump) the string containing your SQL statement, before you execute it.
Also note that including "unsafe" values in the SQL statement makes your code vulnerable to SQL injection. Little Bobby Tables
$sql = "SELECT UserData.Password FROM UserData WHERE UserData.EmailAddress = '"
. mysql_real_escape_string($loginEmail) . "'";
vardump($sql);
$res = mysql_query($sql);
(The vardump
isn't required; it's just there for debugging, a way for us to see the contents of the string that is about to be sent to the database. (When we're debugging a problem, it helps us determine whether the problem is in the SQL text, or whether it's a problem in the database.
We'll want to test whether the call to mysql_query
actually returned a resultset, or whether it returned an error. Once we've verified it's a valid resultset object, we can fetch rows from the resultset. (There's a variety of functions to perform that operation.)
Note: The red box in the documentation that says the mysql extension is deprecated. New code should use either the mysqli or PDO extension.