Jump to content

PHP4 to PHP5 migration issues


ksri

Recommended Posts

facing some problems in migrating website from PHP4 to PHP5.

 

Existing Server

=============

Debian 3.0 stable OS

Apache2.0, PHP 4.4.0-4 and MySQL 5.0.7 environment

Website is database driven and coded in PHP4. 

 

Migrant Server

===========

RHEL 4 Update 4

Httpd 2.0.52, PHP 5.2.4 and MySQL 5.0.45 envoiroment

Same Website coded in PHP4 to be hosted at this server

 

We have been able to edit the contents of the existing web pages. After editing, to preserve the changes, the moment we click on commit button, the whole original page contents vanish. Is there any global variable we can enable in php.ini file for enabling PHP5 environment taking care of PHP4 codes. Any syntax modification for the content edit the insert querry in content_a_commit.php (if at all is recommended to edit it)?

 

Pl look into and guide us as to how this migration could be effected with least changes to code.

 

The PHP pages are edited using an admin module for the operations on existing pages like reformatting, adding new content, changing paragraphs etc..  On editing any existing content(php4 page) the whole page goes blank on committing changes. The field value turns blank from the MySQL end. Any new addition like adding paras etc are well taken without any problems..

 

Thanks for any help in advance May be that some function name change, argument

type change etc can be handled easily if that is to be done The corresponding

pages affected are attached for your reference.

 

 

Related files are

 

Call handler        : call_handler.php

<?
// get installation path

$db_dsn = $CONFIG_DB_HOST;
$db_type = $CONFIG_DB_TYPE;
$db_user = $CONFIG_DB_USER;
$db_pass = $CONFIG_DB_PASS;
$db_name = $CONFIG_DB_NAME;

$terminalnodeid = $_GET['terminalnodeid'];

$res = sql_all("select renderer, authorer,schoolid,deptid from terminalnodes where nodeid = " . $terminalnodeid);

if ($_SESSION['SESSION_HANDLE']=="author"){
$_SESSION['SESSION_HANDLE']="render";
$hlink = $res[0][0];
$_SESSION['SESSION_TERMINALNODEID']="";
} else {
$_SESSION['SESSION_HANDLE']="author";
$hlink = $res[0][1];
$_SESSION['SESSION_TERMINALNODEID']=$terminalnodeid;
}


if(sizeof(explode('?',$hlink))>1) {
$hlink = $hlink . "&";
} else {
$hlink = $hlink . "?";
} 


header("Location: " . $hlink . "&terminalnodeid=" . $terminalnodeid . "&schoolid=" . $res[0][2] . "&deptid=" . $res[0][3]); 

?>

==================================================

commit editing    : content_a_commit.php

==================================================

<?
// get installation path

$db_dsn = $CONFIG_DB_HOST;
$db_type = $CONFIG_DB_TYPE;
$db_user = $CONFIG_DB_USER;
$db_pass = $CONFIG_DB_PASS;
$db_name = $CONFIG_DB_NAME;

$rowid = $_POST['rowid'];

$qry_result = sql("delete from content where nodeid=" . $_POST['terminalnodeid'] . " and rowid=" . $rowid );
$qry_result = sql($qry_query);	

$j=1;
if($_POST['fieldname']!= "") {

$try_text = $_POST['fieldname'];
if ($_POST['replacebr'] =="on") { 
	$_POST['fieldname'] = preg_replace("/\n/", '<br class=tifr>', $_POST['fieldname']);
	$replacebr="yes";
} else {
	$replacebr="no";
}
//$fieldvalue=htmlspecialchars($_POST['fieldname'],ENT_QUOTES);
$fieldvalue=$_POST['fieldname'];
#	$text_query = "insert into content(nodeid,rowid,torder,fieldvalue,fieldtype,replacebr) values(" . $_POST['terminalnodeid'] . "," . $rowid . "," . $j . ",\"" . $fieldvalue. "\",'text','". $replacebr ."')";

#==================

$text_query = "insert into content(nodeid,rowid,torder,fieldvalue,fieldtype,replacebr) values('$_POST[terminalnodeid]', '$rowid','$j','$fieldvalue','text','$replacebr')";
#=======================
$qry_result = sql($text_query);	
//if (!$qry_result) {
//  die('Invalid query: ' . $text_query . " Error : " . mysql_error());
//}
}
$text_query = "";

for($i=0; $i < sizeof($_POST); $i++) {

if($_POST['deleteme' . $i] == "on")
	continue;

if(!$_POST[$i] && $_FILES[$i]['name'] != "") {
	$uploadDir = "../images/content/" . $_POST['terminalnodeid'];
	if (!file_exists($uploadDir)) {
		mkdir($uploadDir);
	}
	$uploadDir .= "/";

	$uploadFile1 = $uploadDir . $_FILES[$i]['name'];

	if (file_exists($uploadFile1)) {
		unlink($uploadFile1);
                }

	move_uploaded_file($_FILES[$i]['tmp_name'], $uploadFile1);
	$filename = $_FILES[$i]['name'];
	$align = $_POST['r'.$i];
	$image_query = "insert into content(nodeid,rowid,torder,fieldalign,fieldvalue,fieldtype) values(" . $_POST['terminalnodeid'] . "," . $rowid . "," . ($j++) . ",\"" . $align . "\"" . ",\"" . $filename . "\",'image')";

	$qry_result = sql($image_query);	
} else {
	if($_POST['h'.$i] != "") {
		$align = $_POST['r'.$i];
		$image_query = "insert into content(nodeid,rowid,torder,fieldalign,fieldvalue,fieldtype) values(" . $_POST['terminalnodeid'] . "," . $rowid . "," . ($j++) . ",\"" . $align . "\"" . ",\"" . $_POST['h'.$i] . "\",'image')";

		$qry_result = sql($image_query);	
	}
}
}


header("Location: content_a.php?terminalnodeid=" . $_POST['terminalnodeid']); 

?>

Link to comment
https://forums.phpfreaks.com/topic/98967-php4-to-php5-migration-issues/
Share on other sites

  • 2 weeks later...

Hi

 

Thanks for the time. I could see that the short tags are 'on' in php.ini

Any other clue?

 

Kausalya

 

You are using short tags "<?" in your scripts. In PHP5, short tags are disabled in the php.ini file by default. Either change all the start tags it "<?php" or edit the php.ini file to turn on short tags.

 

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.