473,320 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 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 3418
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: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.