Update phpMyEdit.class.php (and phpMyEditSetup.php) for PHP version 8 (compatible with PHP v7)
Beta4 adds phpMyEditSetup.php, fixed for PHP v8, to this package.
Based upon Patrick Goupell's Update for PHP version 7 (October 2018) (http://www.yooperlinux.com/sites/default/files/downloads/phpMyEdit-5.8.0.zip) with additional edits and fixes derived from https://kimballrexford.com/phpmyedit-for-php7-and-mysqli/, as well as contributions (described in phpMyEdit.class.php at Top-of-File) by Frédéric Aeberhard
Tested under PHP v8.1.3 (Android/Termux, Windows), v7.4.1 (Linux/Centos7), and v7.3.3 (Windows), using a basic calling program generated by "phpMyEditSetup.php", as well as more complex, legacy calling programs of my own.
A (perhaps overly ambitious) goal of this release was to produce a Development version that generates no Errors, Warnings, or Notices (a goal largely realized with the tested calling programs). Accordingly, "error_reporting = E_ALL", to reveal additional undetected errors, or errors introduced by updates. Two versions of phpMyEdit.class.php for PHP v7 are known to me; both produce about 2.5Mb of Notices & Warnings with E_ALL after a single run of my calling programs, although both do conclude successfully in PHP v7 (both throw fatal errors in PHP v8). Note that earlier versions of phpMyEdit had similar error rates. Many of these errors are glaring and seem to occur by design, perhaps as an odd method of steering the program.
For Production use, change "E_ALL" to "E_ALL & ~E_NOTICE" (line 3304).
YMMV: Your mileage may vary! Compare this code to earlier versions of phpMyEdit if you encounter errors.
PHP's "htmlspecialchars()" function is modified in this version to become "htmlspecialchars($myString,ENT_SUBSTITUTE,'UTF-8',true);" via the added global function "fhtmlspecialchars()" (at Top-File), to which all htmlspecialchars calls are redirected.
This version of phpMyEdit offers one optional tweak, which ensures that after Viewing or Changing any record, the calling program returns to and focuses upon that record instead of the first record on the page.
It sets a $_SESSION['lastrec'] variable that contains the record number being Viewed or Changed.
The option is disabled by default. If you implement this option, uncomment the two lines in phpMyEdit.class.php (2254 and 2648) that reference $_SESSION['lastrec']. Additionally, it requires three PHP statements in your client calling programs (if generated by phpMyEditSetup.php, add "head" and "body" elements/tags):
[Near TopFile:]
<?php if(!session_id()){session_start();} if(!isset($_SESSION['lastrec'])){$_SESSION['lastrec']='';} ?>
[In HTML head element:]
echo '<script> function jumpto(lastrec){document.getElementById(lastrec).scrollIntoView({block:"center"});} </script>';
[HTML body tag:]
echo '<body'; if($_SESSION['lastrec']!=''){echo ' onload="jumpto(\''.$_SESSION['lastrec'].'\')"';} echo '>';
Not specifically related to phpMyEdit: For successful UTF-8 character encoding, changes may be required to MySQL configuration. See README.MYSQLI_and_UTF8.md
Feedback, corrections, suggestions, improvement all welcomed.