Jump to content

PHP and mySQL reading from msAccess db - outputs "Object id #"


dcparham

Recommended Posts

[searched, did not see similar topic covered] - My code outputs where should be just a blank[reads in no middle name/field is blank], instead outputs "Object id #[some number here - single digit]" - something like[output fields replaced with anonyms]:

 

Elvis G. Manson III

Elton Object id #4 Pachino

James Teaufast Dean

 

note the "Object id #4"?

 

the Code:

 

<?php //connect to db/cshUsers.mdb database:

$db_conn = new COM("ADODB.Connection");

$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=". realpath("databaseFolder/attorneys/companyDirectory1a.mdb").";";

$db_conn->open($connstr);

if(!$db_conn)

{

print("OOPS!");

}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

$rS = $db_conn->execute("SELECT * FROM Raleigh  WHERE floor='3' ORDER by LastName");

$FirstName = $rS->Fields('FirstName');

$Middle= $rS->Fields('Middle');

$LastName = $rS->Fields('LastName');

 

while (!$rS->EOF)

{

 

$FullName = $FirstName." ".$Middle." ".$LastName;

echo "<font style='font-size: 90%'>".$FullName."</font><br>";

 

$rS->MoveNext();

}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

$rS->Close();

$db_conn->Close();

///////////////////////////////////////////////////////

?>

 

incidentally, not doing the same from same database/table, when using classic ASP, but yet in PHP.

Please help?

<?php //connect to db/cshUsers.mdb database:
$db_conn = new COM("ADODB.Connection"); 
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=". realpath("databaseFolder/attorneys/companyDirectory1a.mdb").";"; 
$db_conn->open($connstr); 
if(!$db_conn)
{
  print("OOPS!");
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$rS = $db_conn->execute("SELECT * FROM Raleigh  WHERE floor='3' ORDER by LastName"); 

while (!$rS->EOF) 
{ 
  $FirstName = $rS->Fields('FirstName'); 
  $Middle= $rS->Fields('Middle');
  $LastName = $rS->Fields('LastName');
  $FullName = $FirstName." ".$Middle." ".$LastName;
  echo "<font style='font-size: 90%'>".$FullName."</font>";
  $rS->MoveNext(); 
} 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$rS->Close();
$db_conn->Close(); 
///////////////////////////////////////////////////////
?>

now this is interesting - i actually get the same result whether the vars are outside the loop or inside; i almost was thanking you for the solution before even trying the code, but the result is the same.  the blanks/spaces/NULL values in the "Middle" field, when displayed, still shows the "Object id #".  thanks so far!

  • 3 years later...

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.