Jump to content

MySQL Not returning?


Twango

Recommended Posts

I have a Table titled "Accounts2"W/ three columns.One titled Usr, the other titled Pw, and the other titled Special.I get the values with this:$username = mysql_real_escape_string($_POST);$sqlm = "SELECT Pw FROM Accounts2 WHERE Usr = '$username'";$resut = mysql_query($sqlm,$con);($con contains the connect info.)I have a form that submits values "U" and "P".U sends the login user's username.P sends the password.I'm testing with a user w/ the user M and pass M.(I know it exists... i have another page with a table listing all)When i useecho $resut;it returns nothing. Please help!

Link to comment
Share on other sites

You should test the values returned by mysql_connect and mysql_select_db before attempting a query. The example here shows how to do that, and how to see what errors might be occurring. You should also check the value of $username to make sure it's what you think it is. var_dump($_POST) is always a good test.If there is no output at all, you may need to check for a syntax error in the rest of the code.FWIW, best practice says to write $_POST['U'] instead of $_POST. PHP will silently correct the mistake for you, but it is still a mistake.

Link to comment
Share on other sites

I should have added that if the code has only one place to generate output, and it fails, you can't tell what kind of error you have if you don't have error reporting turned on. A simple way of testing your syntax in such a case is to echo a word or two at the top of the script. If that fails, you almost certainly have a syntax error.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...