Prepared Statement on Ubuntu shows ERROR, not in Windows
Ok, i got this code which works fine in Windows but not in Ubuntu 11.04.
I got PHP 5.3.5 on both of those OS and same MySQL version.My code
$dba_host='localhost';
$dba_name='root';
$dba_pass='';
$dba_db='sn';
$con=mysqli_connect($dba_host,$dba_name,$dba_pass,$dba_db) or die('Con开发者_高级运维nection Refused !');
$stmt = mysqli_prepare($con, "SELECT UID,Name,Trace from LOGIN where email=? and password=? LIMIT 1"); // Line 50
mysqli_stmt_bind_param($stmt, "ss", $_POST['login'],$_POST['password']);
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt, $uid, $name, $trace);
mysqli_stmt_fetch($stmt);
mysqli_stmt_close($stmt);
Error
Warning: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, boolean given on line 50
Warning: mysqli_stmt_execute() expects parameter 1 to be mysqli_stmt, boolean given on line 51
Warning: mysqli_stmt_bind_result() expects parameter 1 to be mysqli_stmt, boolean given line 52\
Warning: mysqli_stmt_fetch() expects parameter 1 to be mysqli_stmt, boolean given on line 53
Warning: mysqli_stmt_close() expects parameter 1 to be mysqli_stmt, boolean given on line 54
Additional INfo
I am the root user, and i can see the tables through phpMyAdminWarning: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, boolean given on line 50
In that case, apparently, mysqli_prepare doesn't return a mysqli stmt resource, but a boolean (most probably "false"). You can request the latest error mysqli has returned as follows:
$query = "SELECT UID,Name,Trace from LOGIN where email=? and password=? LIMIT 1";
if( !mysqli_prepare( $con, $query ) ) {
echo mysqli_error( $con );
}
That will display what actually went wrong. Learn defensive programming: don't assume a function will always work, as bad things will happen sooner or later.
As per my understanding it is problem of connection i can see there is blank password...i have also running with ubuntu.In ubuntu you have to give the password @ configuration time for mysql root account so Please cross check with that. I am pretty sure that you have connection problem. Please check it if anything else give me comments i will resolve it
Please also check with your table LOGIN with same name in database.
Usually database name or Table name is Case Senstive.
I found the error; PHP/MySQL in Ubuntu is not smart enough to find the table if the identifier's case does not match. So table LOGIN
and login
are completely different.
精彩评论