Jump to content

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


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