|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
ms access sql wildcard with php
I'm running access 97 with pws and php. When I execute an sql statement with LIKE and a wild card like below it doesn't return anything. When I copy and paste the same sql statement into access as a query it returns 7 results. When I run a SELECT * FROM Address query with the code below I get 10 results. Is there a bug that's causing this or is something wrong with my code.
$strSQL = "SELECT * FROM Address WHERE Name Like '".str_replace("'","''",$Name)."*' ;"; $results = odbc_exec($odbc, $strSQL); if (!$results) { Error_handler( "Error in odbc_exec( no cursor returned ) " , $odbc ); } echo "<TABLE>"; echo "<FORM NAME=\"radioForm\">"; $nbrow=0; //Local variable to count number of rows while( odbc_fetch_row( $results ) ) { $nbrow++; $Index= odbc_result( $results, 1 ); // get the field "Index" $FirstName= odbc_result( $results, 2 ); // get the field "FirstName" $LastName= odbc_result( $results, 3 ); // get the field "LastName" $PhoneNumber= odbc_result( $results, 4 ); // get the field "PhoneNumber" echo "<tr><td>$Index</td><td>$FirstName</td>". "<td>$LastName</td><td>$PhoneNumber</td></tr>\n"; } echo "<tr><td colspan=2>$nbrow entries </td></tr></table>"; |
|
#2
|
|||
|
|||
|
The SQL wildcard character is % not *
|
|
#3
|
|||
|
|||
|
Thanks, I got * from the Access 97 help when I looked up the LIKE statement. Even in an example sql statement it used * as the wildcard. I wasn't thinking and assumed that php would use the same wildcard. Thanks for your help.
|
|
#4
|
||||
|
||||
|
it's not a php wildcard
it has to be an access wildcard see if this helps: http://www.devguru.com/features/kno...se/A100219.html |
|
#5
|
|||
|
|||
|
Quote:
PHP isn't using the wildcard. The statement gets passed down to the database server which then executes the statement using the wildcard. PHP does not know anything about parsing and executing SQL |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > ms access sql wildcard with php |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|