Click to See Complete Forum and Search --> : Upgrade from php 5.0.1 to any breaks scripts...


RoddieRod
08-24-2006, 10:26 AM
Hello All,

This is my first post here and I've been troubleshooting this for days so here it goes.

I have a test server:

Windows 2000 all current patches.
Apache 2.0.59
PHP 5.0.1 (try to upgrade to a version that will stop the security people from complaining)


Now the problem is this, I have a web application that has been running for 2 years now using PHP 5.0.1 when I upgrade to any version of PHP higher than that pages that have form post just don't work anymore. I can't figure this out because EVERYTHING is exactly the same except the version of PHP.

Here is a small example:

This is the relevant code from a simple password recovery page, called getpassword.php


<form action="getpasswordaction.php" method="post">
<h2 id="logintag" class="Rcontent">
Login Name:
</h2>
<input id="loginbox" type="text" name="name" />

<h2 id="question" class="Rcontent">
Challenge Question:
</h2>
<select id="questionbox" name="question" />
<option value=""> -- Select Your Challenge Question -- </option>
<option value="MOMNAME"> Mother's Maiden Name</option>
<option value="PETNAME"> Pet's Name </option>
<option value="PARENTJOB"> Parent's Last Employer </option>
</select>

<h2 id="answer" class="Rcontent">
Answer:
</h2>

<input id="answerbox" type="text" name="answer" />
<h2 id="emailtag" class="Rcontent">
Email Address:
</h2>
<input id="emailbox" type="text" name="email" />
<input id="EnterButton" title="Login" type="submit" name="login" value="Submit" />

<input id="CancelButton" title="Cancel" type="button" value="Cancel" onclick="window.location='/Login.php'" />
</form>



This is part of getpasswordaction.php:


<?
session_start();
require_once('/opr/include/opr-db-functions.inc.php');
require_once('/opr/include/opr-constants.inc.php');
require_once('/opr/include/ccbh-email.class.php');
require_once('/opr/include/opr-functions.inc.php');
require_once('/opr/include/ccbh-web-user.class.php');

$connection = new DB_Connect(WEBMAN_NAME,WEBMAN_PASSWORD,TEST_SERVER,WEBUSER_DATABASE);

$webuser = new CCBHWebUser();
$webuser->setUserName($_POST['name']);

$_SESSION['page_name'] = 'getpasswordaction.php';

LogAction('looking up user: '.$_POST['name'],'passwd_recover');

$userlookup = $connection->Execute("select * from table where var = '".$webuser->getUsername()."'");



The problem is that $_POST['name'] (or anything else that should be) is not populated and this is causing everything else to fail.

Now again everything works perfect with PHP 5.0.1 but any other version causes the above code not to work. I have tried version 5.0.5, 5.1.4, 5.1.5 and 5.1.5-dev but they all produce the same effect.

Any insight would be great!!

Rod

thorpe
08-24-2006, 10:32 AM
Does this produce anything?

print_r($_REQUEST);

RoddieRod
08-24-2006, 10:47 AM
Strange....

if I place the print_r right after the require_once statements I get a valid array of information from the $_POST.

But if I place it after these lines:


$connection = new DB_Connect(WEBMAN_NAME,WEBMAN_PASSWORD,TEST_SERVER,WEBUSER_DATABASE);
$webuser = new CCBHWebUser();
$webuser->setUserName($_POST['name']);


I get nothing...

RoddieRod
08-24-2006, 10:58 AM
OK there is something will my DB_Connect class that is causing to blow up.

I don't see anything off hand though.


<?php
require_once('c:/PHP5/includes/adodb/adodb-exceptions.inc.php');
require_once('c:/PHP5/includes/adodb/adodb.inc.php');

class DB_Connect{
public $Error;
public $Successful;
public $Connection;

public function __construct($uname, $pword, $server, $database){
$this->Connection = new COM("ADODB.Connection"); //ADONewConnection('mssql'); //
try {

$this->Connection->open("Provider=SQLOLEDB.1;Data Source=$server;Persist Security Info=False;".
"Initial Catalog=$database;User Id=$uname;Password=$pword");


$this->Successful = TRUE;
}catch(exception $e) {
$this->Successful = FALSE;
$this->Error = $e;
}
}

public function Execute($sql_statement){
LogAction("SQL String is: ".$sql_statement,'DB_Connect');
try{
return $this->Connection->Execute($sql_statement);
}catch(exception $e){
$this->Successful = FALSE;
$this->Error = $e;
}
}

public function Close(){
return $this->Connection->Close();
}
}
?>