Jump to content

Recommended Posts

Hello everyone,

 

I need help with some code I have written and although it runs perfectly on my Linux server (Centos 5.1 ruining php 5) I cannot make it work in windows vista with Apache and php 5.2.

 

I have a enteredforms.php page where I have a form and supply the dates to use in the query. On submit I post the dates to the form pross_enteredforms.php where I query the database and return the results.

 

I have supplied the code in question.

The code is following (cleared the details to make it more readable):

$conn = DBManager::getConnection();
$query = "SELECT .....";
$result = $conn->Execute($query);
    if($result==FALSE || $result==NULL)
    throw new DatabaseErrorException($conn->ErrorMsg());
    elseif($result->RecordCount()==0)
    {
	header("Location: enteredforms.php?er=ndata");//here if there are no data fetched I get an error in the entered form page.
  		exit;
}
/*
*if i actualy get data serialize the object in a session variable and go to the displaying page.
*/
$_SESSION['result']=$result;
header("Location: enteredforms.php");

 

Then I have the following code  in the enteredforms.php to get the data

$result = false;
if(isset($_SESSION['result']))
$result = $_SESSION['result'];

if($result)
{
while (($row = $result->FetchRow()))
{
echo "<td width=\"80\"><div align=\"center\">".$row['full_name']."</div></td>";
        echo "<td width=\"100\"><div align=\"center\">".$row['form_name']."</div></td>";
echo "<td width=\"20\"><div align=\"center\">".$row['num_of_forms']."</div></td></tr>";
}

}
unset($_SESSION['result']);

 

I get the fallowing error:

Fatal error: main() [<a href='function.main'>function.main</a>]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "ADORecordset_mssql" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in

 

In the Linux server however this works flawlessly. I cannot understand what is going wrong.

 

Any help would be much appreciated.

thanks,

menwn

 

Have you done what the error message asks - Please ensure that the class definition 'ADORecordset_mssql' of the object you are trying to operate on was loaded before unserialize()  (session_start) gets called?

 

Is session.auto_start turned on in php.ini, are any include statements for your class definitions being executed without errors, and if you are using a built-in class, is it enabled/loaded?

@PFMaBiSmAd

 

You were right. I thought I did included it but it turned out it was in a separate driver file I did not include. (I thought the first one did the Job of including it).

 

Unfortunately now although it works the while loop only produces the first row and does not proceed to the others. I made my php file spit my $query and test it in sql server and it returns correctly. Any ideas why this happens?

 

@POG1

It brings to the surface my masochistic tendencies ;)

I am not sure what you mean.

 

$result is the resulted recordset (object) from the execution of the query. I use adodb5 library for sql interaction

 

If I try to produce the output in the pross_enteredforms.php page I get it right. It seems as if the session['result']

stores only the first row or it gives a false after the first row and show my while stops (I tried a foreach loop with no success).

 

i cannot figure out what is going on...

It's similar to a mysqli result object -

ADORecordSet

 

When an SQL statement successfully is executed by ADOConnection->Execute($sql),an ADORecordSet object is returned. This object contains a virtual cursor so we can move from row to row, functions to obtain information about the columns and column types, and helper functions to deal with formating the results to show to the user.

 

The FetchRow() method -

 

Returns array containing current row, or false if EOF. FetchRow( ) internally moves to the next record after returning the current row.

 

If this is working without errors but is only returning one row, either your data or query only has one row or a php version difference is only giving the last row (an array of data verses an array of pointers to a single object containing the last data.) What is the exact php version of the on line server that works?

I need help with some code I have written and although it runs perfectly on my Linux server (Centos 5.1 ruining php 5) I cannot make it work in windows vista with Apache and php 5.2.

 

It's probably more likely a difference between PHP 5.1 and 5.2.

Thank you for your help.

 

The php version is 5.1.6 (it is the cetnos rpm).

 

Moreover, the results are more than one row. (it displays the first row).

 

What drives me crazy is that I can fetch the whole recordset if I display the results in the page that executes $result = $conn->Execute($query);

It fetches the whole recordset.

 

The problem is when I use the $_SESSION variable.

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.