I discovered a straightforward PHP inventory script that seems ideal for my primary school system. However, it appears to be written in PHP 4, and XAMPP has advanced since then. Although I’m not a developer, I’m eager to learn how to update it if possible. Can anyone assist me in troubleshooting this code?
Unfortunately, the original developer is uncontactable, but it’s publicly available.
Actions I’ve Taken:
- Downloaded the script
- Executed the SQL and corrected the TYPE issues to Engine (successful)
- Configured the database settings in PHP
- Tried accessing it through a browser (Chrome)
Upon access, I encountered the following error:
Fatal error: Call-time pass-by-reference has been removed in C:\xampp\htdocs\Inventory\lib\site.php on line 187
Here’s a portion of the code from site.php:
<?php
$sess_path = "./temp/";
function start_session($path, $name) {
global $sess_path, $sess_name;
$sess_path = $path;
$sess_name = $name;
return true;
}
function end_session() {
return true;
}
function fetch_data($session_id) {
global $sess_path, $sess_name;
$sess_file = "$sess_path/session_$session_id";
if ($fp = @fopen($sess_file, "r")) {
$session_data = @fread($fp, @filesize($sess_file));
return $session_data;
} else {
return "";
}
}
function save_data($session_id, $session_data) {
global $sess_path, $sess_name;
$sess_file = "$sess_path/session_$session_id";
if ($fp = @fopen($sess_file, "w")) {
return fwrite($fp, $session_data);
} else {
return false;
}
}
function delete_session($session_id) {
global $sess_path, $sess_name;
$sess_file = "$sess_path/session_$session_id";
return @unlink($sess_file);
}
function clean_up($lifetime) {
return true;
}
session_set_save_handler("start_session", "end_session", "fetch_data", "save_data", "delete_session", "clean_up");
session_start();
?>
I appreciate any guidance you can provide.