clydeshire Posted June 19, 2009 Share Posted June 19, 2009 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. <?php $conn=odbc_connect('patton','','','SQL_CUR_USE_ODBC'); if (!$conn) {exit("Connection Failed: " . $conn);} print('<html> <head> <title>PHP and MS ACCESS</title> </head>'); print('<body>'); print('<table align="center" width=90%>'); print('<tr><th>CardID</th><th>CardName</th><th>Type</th> <th>Expire</th><th>Number</th><th>Credit</th><th>Phone</th> <th>Address</th><th>City</th><th>State</th><th>Zip</th></tr>'); if($conn) { $sql="select * from Patient where `Patient Number`='1'"; $row=odbc_exec($conn, $sql); while(odbc_fetch_row($row)) { $cardid=odbc_result($row,1); $name=odbc_result($row,2); $type=odbc_result($row,3); $expired=odbc_result($row,4); $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>'); } } print('</table>'); print('</body>'); print('</html>'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/162922-access-php-select-query-issue/ Share on other sites More sharing options...
BMurtagh Posted June 23, 2009 Share Posted June 23, 2009 Hello, 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. Quote Link to comment https://forums.phpfreaks.com/topic/162922-access-php-select-query-issue/#findComment-861728 Share on other sites More sharing options...
clydeshire Posted June 29, 2009 Author Share Posted June 29, 2009 This ended up working - \"Field Name\". Quote Link to comment https://forums.phpfreaks.com/topic/162922-access-php-select-query-issue/#findComment-865332 Share on other sites More sharing options...
corbin Posted June 29, 2009 Share Posted June 29, 2009 Hrmmm if Acess (which does not go in the MSSQL board!) is like MSSQL, then you might need to put it in []. Something like: SELECT * FROM [blah]; Quote Link to comment https://forums.phpfreaks.com/topic/162922-access-php-select-query-issue/#findComment-865388 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.