sepoto Posted December 4, 2012 Share Posted December 4, 2012 <?phprequire_once('include.securelogin.php'); $tValue = $_POST['username']; $mysqli = new mysqli($ad_host, $ad_user, $ad_password, "mysql"); if ($mysqli->connect_errno) { printf("Connect failed: %s\n", $mysqli->connect_error); exit();} $tSQL = "select * from `mysql`.`user` where user = \"" . $tValue . "\""; if ($result = $mysqli->query($tSQL) && $result->num_rows > 0) { $result->close(); echo("username#matched");}else { } ?> If I pull $tSQL out of my Netbeans debugger, remove the opening quote and closing quote and run the query I get some results from the table `mysql`.`user`. For some reason nothing is ever returned into the variable $result though. Could this be some kind of permissions problem on the back end of MySQL somewhere? I thought I had a good idea to create some database users with some permissions and query them from `mysql`.`user` with mysqli but it has really not been working out so far. Any suggestions on how to get things working? Thanks!!! Link to comment Share on other sites More sharing options...
sepoto Posted December 4, 2012 Author Share Posted December 4, 2012 I verified this again be writing the script again and copy pasting this much easier query. I get rows out of MySQL workbench no problem however MySQLi return nothing into $result. I am really perplexed here... <?phprequire_once('include.securelogin.php');$mysqli = new mysqli($ad_host, $ad_user, $ad_password, "mysql");if ($mysqli->connect_errno) { printf("Connect failed: %s\n", $mysqli->connect_error); exit();} $tUserName = "root";$tPassword = "**********"; $tSQL = 'select * from `mysql`.`user` where user = "' . $tUserName . '" and password = PASSWORD("' . $tPassword .'")';echo $tSQL; if ( $result = $mysqli->query($tSQL) ) {echo $result->num_rows(); $result->close();} ?> Link to comment Share on other sites More sharing options...
justsomeguy Posted December 4, 2012 Share Posted December 4, 2012 It could be a permission problem. It would probably be better to show an error message if the query didn't succeed so that you don't need to guess what the problem is. http://www.php.net/manual/en/mysqli.error.php 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now