PHP Classes

Mysql to Mysqli package

Recommend this page to a friend!

      PHP MySQL to MySQLi  >  All threads  >  Mysql to Mysqli package  >  (Un) Subscribe thread alerts  
Subject:Mysql to Mysqli package
Summary:No change, code still broken
Messages:6
Author:C Pollock
Date:2016-12-13 11:06:10
 

  1. Mysql to Mysqli package   Reply   Report abuse  
Picture of C Pollock C Pollock - 2016-12-13 11:06:10
I must be doing something wrong. I have in put the link <?php
include_once('includes/mysqli/mysql2i.class.php'); ?> at the head of my index.php file, but it changes nothing. Sorry if this is a dumb post

  2. Re: Mysql to Mysqli package   Reply   Report abuse  
Picture of Dave Smith Dave Smith - 2016-12-13 14:32:07 - In reply to message 1 from C Pollock
Try changing include_once to require_once to see if the class is actually being loaded.

Then at the bottom of the mysql2i.class.php file locate and change include('mysql2i.func.php'); to require_once('mysql2i.func.php');

If the script throws an error that it can't find the required file, it should give you an idea where you are having problems with the path.

If it is just a blank page, then you are going to need to check your error logs.

If it actually made it past the require, then we will need to debug a little bit further.

Dave

  3. Re: Mysql to Mysqli package   Reply   Report abuse  
Picture of C Pollock C Pollock - 2016-12-14 03:21:43 - In reply to message 2 from Dave Smith
Hi Dave,
Thanks for the prompt reply. Changed the include_once to require_once at the start of my index.php file, but made no difference. Page still loads with all the usual error messages regarding deprecated extensions. I introduced a deliberate path error and got a blank page with the expected 'unable to find file' error, so it seems the mysql2i.class.php is loading. At this stage I am simply trying to get my database to load properly - I have a 10-year old site built with the old InterAKT MXShop software, and my hosting company has just switched to PHP 5.6, so the code no longer works. This is my primary problem code:

<?php
$host = 'localhost';
$database = '*****';
$username = 'root';
$passwd = '********';

$dbarc= mysql_pconnect($host, $username, $passwd) or trigger_error(mysql_error(),E_USER_ERROR);
?>

It is in a root folder /Connections and is called as a require_once by the index.php file. Any thoughts or suggestions, other than starting over from scratch?
Regards,
Chris

  4. Re: Mysql to Mysqli package   Reply   Report abuse  
Picture of Dave Smith Dave Smith - 2016-12-14 08:52:08 - In reply to message 3 from C Pollock
If it is PHP 5.6, this class will have no effect, it will just sit there waiting for the MySQL extension to go away in PHP 7.

You are getting the deprecated error message because your error_reporting is set wrong for production. If you have a common initialization script, the error_reporting should be set there in the first line. If you don't, make this your first line in your index.php file.

error_reporting(0);

Dave

  5. Re: Mysql to Mysqli package   Reply   Report abuse  
Picture of C Pollock C Pollock - 2016-12-15 00:57:08 - In reply to message 4 from Dave Smith
Thanks for your help, Dave. The site is remotely hosted, and my code no longer runs on PHP 5.6. I think the time has come to abandon it & start over.
Regards,
Chris

  6. Re: Mysql to Mysqli package   Reply   Report abuse  
Picture of Patrick Schulz Patrick Schulz - 2016-12-21 13:53:34 - In reply to message 1 from C Pollock
You must not include / require the shim at the end of your script / index.php but at the beginning, before you call any of the mysql_* functions.
If you include it just at the very last moment, your code will always fail with an "Call to undefined function ..." error, because they have not yet been defined before.

Instead of include you can also use require, just to see if your include_path settings are correct.

 
For more information send a message to info at phpclasses dot org.