Jump to content

[SOLVED] local variables not holding their values after recordset closes


rwiltfon

Recommended Posts

Hello,

I am a newbie to PHP, and have run across a puzzling problem.  I have the following script:

 

************************************************************************

<?php

 

$conn = new COM ("ADODB.Connection")

or die("Cannot start ADO");

 

//define connection string, specify database driver

$connStr = [connection string supressed];

$conn->open($connStr); //Open the connection to the database

 

$sql = "SELECT * FROM portal.dbo.portal_setup WHERE strServerName = '" . $_SERVER['HTTP_HOST'] . "'";

$rs = $conn->execute($sql);

if (!$rs->EOF) {

$strPortal = $rs["strPortal"];

}

echo "x. " . $strPortal . "<BR>";

$rs->close();

echo "y. " . $strPortal . "<BR>";

 

?>

***************************************************************************

And I get the following error:

Catchable fatal error: Object of class variant could not be converted to string

 

it's happening on echo "y. " . $strPortal . "<BR>"; after I close the recordset

 

I'm getting records back, because when I echo "x. " . $strPortal . "<BR>"; the value is there.  So it seems to be that there is a pointer to the record within the recordset which I don't want.  I want the local variable to hold the value of the record so I can close the recordset and just use the local variable in other parts of the page.  Any suggestions would be most welcome!  Thank you.

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.