Hi
I've been using mysqli and recently moved a website to a new server hosting company. They have recently informed me that the version of PHP they use does not support mysqli.
I'm not really sure about the why/why not's etc but could I just change all instances of mysqli to mysql and get the same results?

Many thanks for any advice on this...

// Connect to the database
$dbc = mysqli_connect("host", "username", "password", "dbname");

// Grab the user-entered log-in data
$user_username = mysqli_real_escape_string($dbc, trim($_SERVER['PHP_AUTH_USER']));
$user_password = mysqli_real_escape_string($dbc, trim($_SERVER['PHP_AUTH_PW']));

// Look up the username and password in the database
$query = "SELECT reg_id, username FROM user_registration WHERE username = '$user_username' AND password = SHA('$user_password')";
$data = mysqli_query($dbc, $query);

if (mysqli_num_rows($data) == 1) {
// The log-in is OK so set the user ID and username variables
$row = mysqli_fetch_array($data);
$reg_id = $row['reg_id'];
$username = $row['username'];

As long as you are not using the object version of mysqli, removing the 'i' would probably suffice.

If your hosting company is telling you their version of php does not support the mysqli extension then you should quickly find a new host. This would indicate to me either they are still running php 4, php 5 was release in july 2004, or they are to stubborn/lazy to enable what I would consider a standard php extension at this point, it is included with PHP 5 by default.

Mysqli provides many benefits over the mysql extension and they are not equals in any way. That is of course unless your host is also running a very old version of mysql as well (e.g. < 4.1). This considering 5.0, 5.1, 5.5 are all stable releases and 5.6 is well on it's way to becoming the next stable release.

Mysql is not actively developed, only minor maintenance releases. Mysqli is actively developed, recommended by MySQL as the preferred development extension, supports character sets, prepared statements, stored procedures, and multiple statements just for starters. It also supports the additional features and options in MySQL 4.1+, which the mysql extension does not.

Great thanks for the advice. I will get onto the host provider immediately!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.