phpMyEdit for PHP7 and MySQLi

Posted on Categories Projects, TechnologyTags , Comments 45 Comments

Note: An updated version of phpMyEdit that is compatible with PHP7 and PHP8 is available on GitHub, maintained by Rajah01:

I’ve stated using the GitHub/Rajah01 version.
– Kimball
April 2022

One of my clients uses phpMyEdit but unfortunately when we updated their web hosting account to PHP 7, phpMyEdit v5.7.1 stopped working. The changes required to phpMyEdit to make it work are pretty simple, mainly update the __construct function and migrated mysql_* calls to mysqli_*. My updated version of phpMyEdit is available for download below.

Here are the errors phpMyEdit v5.7.1 was throwing on PHP 7:

[03-May-2019 08:53:30 CST6CDT] PHP Fatal error:
Uncaught Error: Call to undefined function mysql_connect() in /home/.../public_html/.../phpMyEdit.class.php:317
Stack trace:
0 /home/.../public_html/.../phpMyEdit.class.php(3072): phpMyEdit->sql_connect()
1 /home/.../public_html/.../phpMyEdit.class.php(3111): phpMyEdit->connect()
2 /home/.../public_html/.../phpMyEdit.class.php(3372): phpMyEdit->execute()
3 /home/.../public_html/.../edit.php(169): phpMyEdit->phpMyEdit(Array)
4 {main}
thrown in /home/.../public_html/data/phpMyEdit.class.php on line 317

To upgrade phpMyEdit v5.7.1 to PHP 7+ I made the following changes:

  • the __construct functions
  • migrated the mysql_* calls to mysqli_*

You are welcome to use my updated copy of the phpMyEdit class file. Here is a download link to the class file with my changes:


Published by


Kimball is a website designer and developer in Goffstown, NH.

45 comments on:
“phpMyEdit for PHP7 and MySQLi”

  1. Hi Kimball,
    Since I’ve re-org’d almost all of my tables into one database, is there somewhere in the phpMyEditSetup.php that the hostname, username, password, and table can be entered so they are pre-filled in the Setup form?

    Appreciate your support of phpMyEdit and you tech help on issues.

  2. I am unable to execute php file when apply any operation like Add/Change/Delete with PHP8
    Here is the code:
    $opts[‘fdd’][‘associated_images’] = array(
    ‘name’ => ‘Associated Images’,
    ‘select’ => ‘T’,
    ‘sort’ => false,
    ‘php’ => ‘record_image_process.php’,
    ‘table’ => ‘Image’,
    ‘related_table_this_index’ => 0,
    ‘sql’ => ‘(SELECT `image_location` FROM `Image` as i WHERE i.record_id = PMEtable0.record_id)’,
    ‘help’ =>

    Description: Images of the work.
    ‘options’ => ‘ACPVDL’

    It process the file record_image_process.php on list view.

    Your help is much appreciated.

    1. Are you using the phpMyEdit version from Rajah01 on github? Here:
      Try that version. If you still have trouble post the issue on github, but be sure to include the error message in addition to your code samples.

      We have not use the execute php feature (like: ‘php’ => ‘record_image_process.php’) so we have never seen that issue before.

  3. Anyone managed to get phpMyEdit.class.php to work under PHP v8? Every updated version I’ve tried (Kimball, Platon, etc) works under PHP v7.33; none of them work with PHP v8.

      1. That will be great. I hope you are able to release a working version, or at least document the necessary changes. Relied on this wonderful tool for about 20 years, and all of a sudden … dead as a doornail, and not even an error message!

      2. I got phpMyEdit to work in PHP v8.0.13, both in Win10 and Android 10.
        Made these minimal changes to your (Kimball) version dated 11-11-2020 (
        line 466:
        $qparts[‘select’]{strlen($qparts[‘select’]) – 1} = ‘)’;
        changed to
        $qparts[‘select’][strlen($qparts[‘select’]) – 1] = ‘)’;
        line 530:
        $ret{strlen($ret) – 1} = ‘)’;
        changed to
        $ret[strlen($ret) – 1] = ‘)’;
        Comment out (// …) lines 1723, 1730, and 1738.
        It runs! Many MANY warnings with E_ALL & ~E_NOTICE (there are no warnings under PHP v7.33!), but my database displays and operates correctly. Obviously, I’m missing some core inconsistencies between v7 and v8, but it’s a starting point …

        1. Made a few more tweaks; now I am seeing ZERO Errors, Warnings, or Notices under PHP v8.0.13 (or PHP v7) using “error_reporting=E_ALL”. 100% clean runs.

          This PHP7/8 version is based on Patrick Goupell’s PHP7 update. The file and comments are published at github (see below). Give it a try — feedback and improvement welcomed.


  4. Thanks for everyone’s help. It appears that not all of the old features are supported for the newer version on the website.

    I’m still having problems with old code that used the old way for orderby:
    $opts[‘fdd’][‘Employee_ID’][‘values’][‘orderby’] = ‘Last_NM’; // optional ORDER BY clause

  5. TY. I managed to reuse that old piece of software.
    It works well now, but I still have to understand how to use the phpMyEdit-report.class.php extension.
    It gives a blank page and these errors:

    [Fri Jan 15 18:43:10.662259 2021] [php7:warn] [pid 26639] [client a.b.c.d:50794] PHP Warning: Declaration of phpMyEdit_report::display_list_table_buttons($total_recs, $position) should be compatible with phpMyEdit::display_list_table_buttons($position, $listall = false) in /usr/local/phpMyEdit-PHP7.0-master/extensions/fm-report.class.php on line 33
    [Fri Jan 15 18:43:10.662351 2021] [php7:error] [pid 26639] [client a.b.c.d:50794] PHP Fatal error: Uncaught Error: Call to undefined method phpMyEdit::phpMyEdit() in /usr/local/phpMyEdit-PHP7.0-master/extensions/fm-report.class.php:42\nStack trace:\n#0 /webs-fm/www/mincoll/report.php(145): phpMyEdit_report->phpMyEdit_report(Array)\n#1 {main}\n thrown in /usr/local/phpMyEdit-PHP7.0-master/extensions/fm-report.class.php on line 42

    1. I don’t know. I guess my client is not using the feature, because that error did not come up.

      It just a “PHP Warning”, so the code should still run bast the error. So maybe there is something else wrong as well.

  6. Thank you very much

    I would like to point out a mistake:
    line 1546, in function htmlSelect(
    foreach($selected as $val) $selecte2[]=(string)$val;
    change $selecte2 by $selected2

    1. Awesome! Glad it helped Eric.

      Did your web hosting just now give you the option to upgrade to PHP 7? (if so what hosting company do you use?) Or were you holding off for some other reason?

  7. Thank, highly appreciated.

    Found a small bug.
    Warning: preg_replace(): Unknown modifier ‘+’ on line 1447
    I removed the +

  8. Thank you, thank you, I’ve been looking for phpMyEdit version that works with PHP 7 for a couple of weeks now.
    However, on my server it is throwing an error:

    [27-Feb-2020 07:40:43 UTC] PHP Notice: Undefined variable: HTTP_SERVER_VARS in /var/www/html/new.php on line 72
    [27-Feb-2020 07:40:43 UTC] PHP Fatal error: Uncaught Error: Call to undefined function ereg_replace() in /var/www/html/pme/phpMyEdit.class.php:1447
    Stack trace:
    #0 /var/www/html/pme/phpMyEdit.class.php(2471): phpMyEdit->cellDisplay(7, Array, 'pme-cell-0')
    #1 /var/www/html/pme/phpMyEdit.class.php(3192): phpMyEdit->list_table()
    #2 /var/www/html/pme/phpMyEdit.class.php(3379): phpMyEdit->execute()
    #3 /var/www/html/new.php(107): phpMyEdit->__construct(Array)
    #4 {main}
    thrown in /var/www/html/pme/phpMyEdit.class.php on line 1447

    I wonder if you might find the time to take a look and see if you can tell what is going wrong.

    1. ereg_replace was removed in PHP 7.0.
      Change /pme/phpMyEdit.class.php line 1447 from:
      $value = ereg_replace("[\r\n\t ]+",' ',$value);

      to this:
      $value = preg_replace("[\r\n\t ]+",' ',$value);

      The other error is from your new.php file, line 72. HTTP_SERVER_VARS is no longer supported, but I can’t tell what you are doing with it enough to suggest a replacement.

      1. Fantastic! Changing that line cleared the error and phpMyEdit is working again. Thank you so much,
        The new.php had this line (generated by the old phpMyEdit):
        $opts[‘language’] = $HTTP_SERVER_VARS[‘HTTP_ACCEPT_LANGUAGE’];
        I removed it and have not noticed any consequences.

        FYI – for those who might want something more powerful, Doug Hockinson, one of the originals of phpMyEdit is maintaining his own port of it at his web site – I’ve checked it out and it works great but for me it would require too much converting of existing files. Someone starting out fresh might benefit from checking it out.

        1. The replacement for
          $opts['language'] = $HTTP_SERVER_VARS['HTTP_ACCEPT_LANGUAGE'];

          would be
          $opts['language'] = $_SERVER['HTTP_ACCEPT_LANGUAGE'];

      2. Thank you! I modified phpMyEdit.class.php and no longer have an error trying to trim field lengths in my List view. Please note I had to remove the + as well.

        $value = preg_replace(“[\r\n\t ]”,’ ‘,$value);

  9. Works very well! My edit class stopped working when I had to update to PHP 7.2. I just copied in Kimball’s version and it was up again. Thank you !

  10. Thank you for saving me so much time and trouble! I looked into the errors and realized what was going on. I temporarily fixed it by switching just that site’s PHP version down but hadn’t even dug into what all would need to be fixed. When I started the search your fixes where right there.

    Again, thanks for sharing this!

  11. I am trying to install phpMyEdit-5.7.1 on a Centos 7 with php 7.2. The phpMyEdit.Setup.php program throws this error in the logs

    "PHP Fatal error: Uncaught Error: Call to undefined function mysql_pconnect() in /var/www/html/phpmyedit/phpMyEditSetup.php:165\nStack trace:\n#0 {main}\n thrown in /var/www/html/phpmyedit/phpMyEditSetup.php on line 165, referer: http://localhost/phpmyedit/"

    Even after I replaced the phpMyEdit with the revised one from the link above, I am not able to get it running.

    I am not very familiar with the @mysql_pconnect syntax and how to replace it with the newer mysqli compatible syntax. Will be grateful for any pointer to a solution.

  12. Can you help me where to put in phpMyEdit class file

    // Change character set to utf8

    1. At line 318, like so….

      function sql_connect() /* {{{ */
      $this->dbh = @ini_get('allow_persistent')
      ? @mysqli_pconnect($this->hn, $this->un, $this->pw)
      : @mysqli_connect($this->hn, $this->un, $this->pw);
      mysqli_set_charset($this->dbh, "utf8");

      } /* }}} */

    2. Modify the function sql_connect() with adding the follow 2 lines worked for me !!!

      function sql_connect() /* {{{ */
      $this->dbh = @ini_get('allow_persistent')
      ? @mysqli_pconnect($this->hn, $this->un, $this->pw)
      : @mysqli_connect($this->hn, $this->un, $this->pw);

      mysqli_query($this->dbh,"set character_set_client='utf8'");
      mysqli_query($this->dbh,"set character_set_results='utf8'");

      } /* }}} */

Leave a Reply

Your email address will not be published. Required fields are marked *