Jump to content

ACCESS & PHP Select Query Issue


Recommended Posts

I have a client who needs a portal web page built so their clients can access limited information from their database.  The unfortunate part is the program they are using (and don't/won't replace), uses ACCESS as it's database.


My ODBC connection works great.  My problem comes when I try to retrieve information from a field name that has a space in it, i.e. Patient Number.  I can't change the field names and no matter what I use to enclose it (`,', or "), it doesn't seem to work.  I get the "no tuples..." error message.  Is there anything else I can try to solve this situation?


Thanks for your help.



if (!$conn)
  {exit("Connection Failed: " . $conn);}



<title>PHP and MS ACCESS</title>



print('<table align="center" width=90%>');




$sql="select * from Patient where `Patient Number`='1'";
$row=odbc_exec($conn, $sql);

          $card_num =odbc_result($row,5);
          $credit =odbc_result($row,6);
          $phone =odbc_result($row,7);
          $address =odbc_result($row,;
          $city =odbc_result($row,9);
          $state =odbc_result($row,10);
          $zip =odbc_result($row,11);

print('<tr><td>'.$cardid.'</td><td>'. $name.'</td><td>'.$type.'</td><td>'.$expired.'</td><td>'.$card_num.'</td><td>'.$credit.'</td><td>'. $phone.'</td><td>'.$address.'</td><td>'.$city.'</td><td>'.$state.'</td><td>'.$zip.'</td></tr>');


Link to comment
Share on other sites



The backticks (`) should be the proper formatting for this according to PHP's legal-names. However, can you set the code to use the backticks and copy the error to here? I think pasting the exact output error and/or the apache error_log would help those who view the thread more info to help out.



Link to comment
Share on other sites


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.