472,805 Members | 938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 software developers and data experts.

Migrated from PHP4 to PHP5, index.php did not run as expected

3
Hi all,

I recently given a task to upgrade a running server (PostgreSQL7.3+Apache2.0+PHP4.2) to a new server with PostgreSQL8.1+Apache2.2+PHP5.1 installed (all Fedora Core 6 packages). All is running well, except the old php scripts. Plz bare with me I'm not a programmer, I've spent a month researching the PHP manual, the net, other forum and still can't exactly point out the porblem.

I have set register_globals on and allow_call_time_pass_reference to true for backward compatibilty in order for these old php scripts to work in PHP5. The problem is I get immediate disconnection (session ended) after a succesfull db connection in the index.php script.

Things I know that works in index.php are:
[PHP]<?
require("/home/*/lib/config.inc.php");
$conn=new DBConnection ($DBNAME,$DBUSER,$DBPASS,$DBHOST,$DBPORT);
[/PHP] This worked becaused it was logged in my postgresql logger as follow:
LOG: connection received: host=[local]
LOG: connection authorized: user=xxxx database=xxxx
LOG: disconnection: session time: 0:00:00.01 user=xxxx database=xxxx host=[local]

[PHP]if(!$conn->init()){
//Connection to the database is not established
echo "<center><br><br>Sorry this site is currently not available</center><br>".$conn->getError();
exit();
}[/PHP] This worked when i turn off postgresql.

I can't do this:
[PHP]require("checkuser.inc.php");
if($USER_ISLOGIN) {
include("mainmenu.inc.php");
include("loginindex.inc.php");
} else {[/PHP] Before it can check table users in the database the connection was ended or there was no connection established.

Here is the complete code off index.php, I hope somebody out there can point out the problem.
[PHP]<?php
require("/home/*/lib/config.inc.php");

//$lvc_include_dir = 'kunjung/inc/';
//include ($lvc_include_dir.'new-visitor.inc.php');
$conn=new DBConnection ($DBNAME,$DBUSER,$DBPASS,$DBHOST,$DBPORT);

if(!$conn->init()) {
// Connection to the database is not established
echo "<center><br><br>Sorry this site is currently not available</center><br>".$conn->getError();
exit();
}
$res=new DBResult($conn);
$res->execSQL("select * from fg");
$HARINI_FG=array();
while($res->fetchNext()) {
$HARINI_FG[$res->row->id]=$res->row->name;
}
$res->free();
unset($res);

$TMP_TITLE="";
$TMP_NAVTOP=array();
$TMP_CONTENT="";
$TMP_TEMPLATE="";
$TMP_USERNAME="";

function AddTitle($str) {
$GLOBALS["TMP_TITLE"].=$str;
}
function AddNavTop($str,$link="stateid") {
global $PHP_SELF;
if ($link=="stat"){
array_push($GLOBALS["TMP_NAVTOP"],"<a class=link href='kunjung/index.php'>$str</a>");
}else{
array_push($GLOBALS["TMP_NAVTOP"],"<a class=link href=$PHP_SELF?stateid=$link>$str</a>");}
}
function AddContent($str) {
$GLOBALS["TMP_CONTENT"].=$str;
}
function setTemplate($str) {
$GLOBALS["TMP_TEMPLATE"]=$str;
}

AddTitle("HARINI RECRUITMENT CREW");
AddContent("<table border=0 cellpadding=0 cellspacing=0 align=center width=80% ><tr><td valign=top>");

require("checkuser.inc.php");

if($USER_ISLOGIN) {
include("mainmenu.inc.php");
include("loginindex.inc.php");
} else {

#AddContent("awal- LOGIN");
# AddNavTop("Home","home");
# AddNavTop("About Us","aboutus");
# AddNavTop("More Info","info");
# AddNavTop("Contact Us","contact");
# AddNavTop("Login","login");

# switch($stateid) {
# case "login" :

AddContent(ThrowMessage("<div align=center>Type in your username and password</center>"));
AddContent(ThrowBoxTop("LOGIN"));
AddContent("<table><form action=$PHP_SELF?loginstate=login&stateid=login method=post><tr><td>Username</td><td><input name=xusername size=15></td></tr>".
#AddContent("<table><form action=$PHP_SELF?loginstate=$logstate method=post><tr><td>Username</td><td><input name=xusername size=15></td></tr>".
"<tr><td>Password</td><td><input type=password name=xpassword size=15></td></tr>".
"<tr><td colspan=2 align=center><input type=submit value=Login></td></tr>".
"<tr><td colspan=2 align=center>$msgloginerror</td></tr>".
"</form>".
"</table>");

AddContent(ThrowBoxBottom());
# break;

/*
case "aboutus" :
AddContent(getFileContent("$HARINI_TEMPLATES/aboutus.html"));
break;

case "contact" :
AddContent(getFileContent("$HARINI_TEMPLATES/contactus.html"));
break;

default :
AddContent(getFileContent("$HARINI_TEMPLATES/welcome.html"));
break;
}
*/
}

AddContent("</td></tr></table>");

setTemplate(getFileContent("$HARINI_TEMPLATES/crew2.html"));

if(!$nothtml) {
$tdwidth=round(720/(sizeof($TMP_NAVTOP)+1));
if($tdwidth>100) $tdwidth=100;
$TMP="<table border=0 cellpadding=0 cellspacing=10 align=center><tr>";
$bil=0;
foreach($TMP_NAVTOP as $key=>$val) {
#$TMP.="<td background=$HARINI_URL/images/bgblue.gif width=$tdwidth align=center valign=middle >$val</td>\n";
#$TMP.="<td width=$tdwidth align=center valign=middle>$val</font></td>\n";
$bil += 1;
if($bil==1){$gab .= "| ".$val." | ";}else{$gab .= $val." | ";}

}
if($gab == " | ")$gab="";
$TMP.="</tr><tr><td colspan=$bil align=center>$gab</td></tr></table>";

if($USER_ISLOGIN) {
$USERNAME="$USER_USERNAME";
$REALUSERNAME="$USER_NAME";
} else {
$USERNAME="Not login";
$REALUSERNAME="-";
}
$TMP_TEMPLATE=str_replace("##title",$TMP_TITLE,$TM P_TEMPLATE);
$TMP_TEMPLATE=str_replace("##username",$USERNAME,$ TMP_TEMPLATE);
$TMP_TEMPLATE=str_replace("##userrealname",$REALUS ERNAME,$TMP_TEMPLATE);
$TMP_TEMPLATE=str_replace("##url-start",$HARINI_URL,$TMP_TEMPLATE);
$TMP_TEMPLATE=str_replace("##iplogin",$REMOTE_ADDR ,$TMP_TEMPLATE);
$TMP_TEMPLATE=str_replace("##date",date("D, d M Y",time()),$TMP_TEMPLATE);
$TMP_TEMPLATE=str_replace("##topmenu",$TMP,$TMP_TE MPLATE);
$TMP_TEMPLATE=str_replace("##content",$TMP_CONTENT ,$TMP_TEMPLATE);
echo $TMP_TEMPLATE;
flush();
}

$conn->close();

#echo "<HEAD> <LINK REL=\"SHORTCUT ICON\" HREF= \"/images\/favicon.ico\"> </HEAD>";

?>[/PHP]

Any help would be much appreciated. Thx all.
Feb 5 '07 #1
3 3320
Motoma
3,237 Expert 2GB
Does your PHP error log report any problems with the script?
Feb 5 '07 #2
abeb
3
Does your PHP error log report any problems with the script?
Hello Motoma,
Yes there were, but does not relate to my problem. Here are the error log:
Notice: Trying to get property of non-object in /home/*/lib/global.inc.php on line 268
Warning: pg_errormessage(): supplied argument is not a valid PostgreSQL link resource in /home/*/lib/global.inc.php on line 268
Notice: Undefined variable: loginstate in /home/*/public_html/checkuser.inc.php on line 36
Notice: Undefined variable: msgloginerror in /home/*/public_html/index.php on line 79
Notice: Undefined variable: nothtml in /home/*/public_html/index.php on line 109
Notice: Undefined variable: gab in /home/*/public_html/index.php on line 121

Hope hearing from you soon.

Best regards.
Feb 6 '07 #3
Motoma
3,237 Expert 2GB
Hello Motoma,
Yes there were, but does not relate to my problem. Here are the error log:
Notice: Trying to get property of non-object in /home/*/lib/global.inc.php on line 268
Warning: pg_errormessage(): supplied argument is not a valid PostgreSQL link resource in /home/*/lib/global.inc.php on line 268
Notice: Undefined variable: loginstate in /home/*/public_html/checkuser.inc.php on line 36
Notice: Undefined variable: msgloginerror in /home/*/public_html/index.php on line 79
Notice: Undefined variable: nothtml in /home/*/public_html/index.php on line 109
Notice: Undefined variable: gab in /home/*/public_html/index.php on line 121

Hope hearing from you soon.

Best regards.
Quick question, are those *'s actualy there, or have you placed them in there for anonymity?
Feb 6 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Tim Tyler | last post by:
I'm sure this is a FAQ - but I could not find a coherent statement of the answer: Some of my clients want PHP4. Other ones want PHP5. Can I run both PHP4 and PHP5 under the same instance of...
0
by: bissatch | last post by:
Hi, I have installed Apache2. I have installed PHP4.3.0. All is working fine. I have now went and tried to install DOMXML into PHP by simply uncommenting the extension = php_domxml.dll (or...
0
by: dk_sz | last post by:
Can anyone point me to a guide or something for conversion? I tryed http://alexandre.alapetite.net/doc-alex/domxml-php4-php5/index.en.html but it doesn't work (not all parts anyway) - and as I...
2
by: dk_sz | last post by:
Can anyone point me to a guide or something for conversion? I tryed http://alexandre.alapetite.net/doc-alex/domxml-php4-php5/index.en.html but it doesn't work (not all parts anyway) - and as I...
2
by: Stefan Huber | last post by:
Hi I've got a really strange problem, and can't find out why it's not working as intended. in order to use php4 and 5 together on a webserver and the requirement for running as different...
12
by: Drazen Gemic | last post by:
How long will PHP4 be supported ? When is PHP4 end of life scheduled ? DG
3
by: xhe | last post by:
I have just upgraded my php version form php4 to php5. and I met this problem, and don't know if you know the solution. My site was written in PHP4, and most parts can be running smoothly in PHP5,...
8
by: FFMG | last post by:
Hi, I am slowly moving my code to php5. But I would like to make it backward compatible in case something bad happens, (and to make sure I understand what the changes are). The way the...
3
by: jmark | last post by:
I am currently running php 4.4.7 in windows xp and apache 2. If I enter php in command line. I get the following error The application has failed to start because php5ts.dll was not found" I...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.