View Full Version : Having trouble getting php4 code working on php5 server

03-13-2008, 11:55 AM
My hosting provider recently upgraded to php5 and one of my php scripts is playing up. I have looked all over the php site for an idea of what part of the code needs changing and have drawn a blank. If anyone has any idea of what needs altering in the below code to get it working on php5, I would be very grateful.

if (($_GET["sub"] == "auto") && (($_GET["action"] == "add") || ($_GET["action"] == "edit"))) {

$_models = $that->db->QFetchRowArray("SELECT * FROM {$that->tables[make]}");
if (is_array($_models)) {
foreach ($_models as $key => $val) {
if ($val["make_parent"] == 0) {
$make[$val["make_id"]] = $val["make_name"];

$js .= "models[{$val[make_id]}] = new Array();\n";
$i = 1;
$js .= "models[{$val[make_id]}][" . $i++ ."] = new Option(\"[ select ]\" , \"\"); \n";
foreach ($_models as $k => $v) {
if ($v["make_parent"] == $val["make_id"]) {
$js .= "models[{$val[make_id]}][" . $i++ ."] = new Option(\"{$v[make_name]}\" , \"{$v[make_id]}\"); \n";

$extra["add"]["after"] = $extra["edit"]["after"] = $that->templates["js"]->Replace(array("script" => $js ));

if (($_GET["sub"] == "auto") && ($_GET["action"] == "details")) {
$task = new CSQLAdmin("photos", $_CONF["forms"]["admintemplate"],$that->db,$that->tables , $extra);
$extra["details"]["after"] .= $task->DoEvents();

Many thanks

03-13-2008, 02:29 PM
There are very few incompatible changes between php4 and php5. Your problem is likely a configuration difference rather than a php version problem. For the same exact server configuration, 99.5% (or more) of php4 code will run unchanged under php5.

The code fragment you posted does not appear to contain any thing that is php configuration dependent or php4/php5 version specific.

Turning on full php error reporting might help you find problems, such as undefined program variables that are no longer getting set because register globals are no longer on...

Posting part of your code and making a vague statement that - "one of my php scripts is playing up" is of zero use for anyone to help you. What specifically is it doing that is wrong? What output are you getting vs what it should be? What symptoms are there? What errors are there?

Re-read your post and tell us if you think it contains any information for someone to help you. It does not state what it is, what is should be doing, or what it is doing (and mind reading does not work over the Internet.) :rolleyes:

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum