L09Luka Posted August 10, 2013 Posted August 10, 2013 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?
wolstech Posted August 10, 2013 Posted August 10, 2013 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.
L09Luka Posted August 10, 2013 Author Posted August 10, 2013 I use PHPMyAdmin and File Manager. How do Icode it to make it work?
Krydos Posted August 10, 2013 Posted August 10, 2013 How do I code it to make it work?Instead of using this php code http://php.net/manual/en/book.mysql.phpUse the equivalent code from this page http://php.net/manual/en/book.mysqli.php
L09Luka Posted August 11, 2013 Author Posted August 11, 2013 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...
Ice IT Support Posted August 11, 2013 Posted August 11, 2013 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.
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