I have developed a website named vishwasthali.org in PHP and have hosted it in IIS7 on a third-party server. Everything else works fine, except for the code for database access that I have written using MySQLi API. The code works fine on the localhost, but not on the server. Using phpinfo()
on the server and my machine, I found that:
(1) On my machine (running in Windows 7 32-bit, Apache hosting environment), the PHP version is 5.3.8, and mysqli version is 5.0.8-dev, and
(2) On the server (running on Windows Server 2008, IIS7 hosting environment), the PHP version is 5.2.14 and mysqli version is 5.0.51a.
Here are the screen shots of phpinfo()
on the server:
Here is the sample of the mysqli code.
session_start();
include_once 'code_files/conn.php';
$stmt = $mysqli->prepare('SELECT * FROM adminusers WHERE Username = ? AND `Password` = ?');
$stmt->bind_param('ss', $_POST['Username'], $_POST['Password']);
$stmt->execute();
$result = $stmt->get_result();
if($result->num_rows > 0)
........
else
........
Using echo get_class($mysqli);
does display mysqli. That means, the code does detect mysqli. But the statement $stmt
is not prepared. Even the $mysqli->error;
does not display any error, might be because of PHP being running on IIS.
Now I have two options, either change the code for database access to classic mysql API, or to upgrade the PHP and MySQLi versions on the server by downloading latest PHP binaries from the php.net. I won't like to go with the first option (that definitely works), hope you know why. The latter is not in my hands. Can't think anything more than these.
I suppose replacing the php_mysqli.dll on might upgrade the mysqli version, not sure. But what about PHP version?
What can I do in this case. Will an upgrade of PHP and MySQLi versions on the server solve my problem? If YES, can it affect other PHP websites running on the server?
Thanks in advance.
echo ($stmt) ? "Statement Prepared" : "No Statement";
, on localhost, it prints 'Statement Prepared', where as on server, it prints 'No Statement'. Simply put, the executing stops as the line where I am preparing the statement and a blank page is displayed (since the above code is in a separate file).