Jump to content

Recommended Posts

Posted

Hi, I recently decided that I will use MySQli.

My question is, how do I upgrade from MySQL to MySQLi.

 

A friend told me that I need to upgrade my PHP to get it.

 

If so how do I upgrade it?

Posted

PHP is a system-wide program that can't be changed/updated by users. Also, mysqli already is installed on Heliohost.

 

You just need to code whatever program you're working on to use it instead of mysql.

Posted

I made a MySQLi

 

mysqli_query(db()

 

and the error Fatal error: Call to undefined function db() in /home/l09luka/public_html/shop/index.php on line 56 came up...

Posted

That doesn't work unless you have defined the function db() and it returns a query to run on the server. Try this code:

<?php
$dbcon = mysqli_connect("localhost","username","password");
if (!$dbcon)
{
die("MySQL error: " . mysqli_connect_error());
}
$query = mysqli_query("SELECT * FROM `cpuser_dbname`.`Table`");
// code to process query
mysqli_close($dbcon);
?>

 

Replacing username and password with the MySQL user and password, and cpuser_dbname and Table with the respective values.

 

IMPORTANT: A huge difference between mysql and mysqli is the query command. Commands that retrieve data from the database (such as SELECT) use the mysqli_query() function. However, commands that edit data (such as INSERT, UPDATE, ALTER, etc.) use the mysqli_real_query() command.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...