MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old April 28th, 2004, 02:55 PM
fark fark is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 3 fark User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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>";

Reply With Quote
  #2  
Old April 28th, 2004, 04:09 PM
shammat shammat is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2003
Location: Munich, Bavaria
Posts: 971 shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 44 m 15 sec
Reputation Power: 57
The SQL wildcard character is % not *

Reply With Quote
  #3  
Old April 28th, 2004, 04:25 PM
fark fark is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 3 fark User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #4  
Old April 28th, 2004, 09:33 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 25th Plane (17000 - 17499 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,343 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 5 Days 8 h 5 m 22 sec
Reputation Power: 891
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
__________________
r937.com | rudy.ca

Reply With Quote
  #5  
Old April 30th, 2004, 02:26 AM
shammat shammat is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2003
Location: Munich, Bavaria
Posts: 971 shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 44 m 15 sec
Reputation Power: 57
Quote:
Originally Posted by fark
I wasn't thinking and assumed that php would use the same wildcard

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

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > ms access sql wildcard with php


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway