473,396 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Odd mysql/php behavior with LIKE clause

The following query:

SELECT rownum from(SELECT @rownum:=@rownum+1 rownum, t.*FROM (SELECT
@rownum:=0) r,
(SELECT Application
FROM application_list_1.application_data_table a ORDER BY Application
asc ) t) s
WHERE Application like '$app%' order by Application asc limit 1

where $app is my search query passed in from an html form. This query
is run in a PHP script. I run it with the following code:

$row = mysql_fetch_assoc($sql);
return $row['rownum'];

This works 100% fine EXCEPT when I pass 'a' or 'A' to the query from
the html form. Every other letter or string works just fine except the
'a' or 'A'. Also, I can run this query within MySQL query browser with
'a' or 'A' and get valid results.

I'm totally confused. What is the problem with the 'a'? Encoding?

Aug 16 '06 #1
1 3534
Found it! There was a problem further on in my code producing the
error. Sorry to bother anyone!
Ro**********@gmail.com wrote:
The following query:

SELECT rownum from(SELECT @rownum:=@rownum+1 rownum, t.*FROM (SELECT
@rownum:=0) r,
(SELECT Application
FROM application_list_1.application_data_table a ORDER BY Application
asc ) t) s
WHERE Application like '$app%' order by Application asc limit 1

where $app is my search query passed in from an html form. This query
is run in a PHP script. I run it with the following code:

$row = mysql_fetch_assoc($sql);
return $row['rownum'];

This works 100% fine EXCEPT when I pass 'a' or 'A' to the query from
the html form. Every other letter or string works just fine except the
'a' or 'A'. Also, I can run this query within MySQL query browser with
'a' or 'A' and get valid results.

I'm totally confused. What is the problem with the 'a'? Encoding?
Aug 16 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Rahul Anand | last post by:
Hi all, I am trying to fetch 5 records, randomly picked and in random order from a MySQL table (MySQL version > 3.23). I wrote my SQL Query as SELECT name,id FROM tablename WHERE active =...
6
by: Xenophobe | last post by:
I know this isn't a MySQL forum, but my question is related to a PHP project. I have two tables. table1 table2 "table1" contains 2 columns, ID and FirstName:
0
by: Philip Stoev | last post by:
Hi all, Please tell me if any of this makes sense. Any pointers to relevant projects/articles will be much appreciated. Philip Stoev http://www.stoev.org/pivot/manifest.htm ...
2
by: sunny076 | last post by:
Hi, I am confused with the syntax for NOT in MYSQL where clause and wonder if an expert in MYSQL can enlighten me. There are possibly two places NOT can go in: select * from employee_data...
20
by: John Wells | last post by:
Yes, I know you've seen the above subject before, so please be gentle with the flamethrowers. I'm preparing to enter a discussion with management at my company regarding going forward as either...
1
by: Kenneth P | last post by:
Hi, I'm trying to do some Custom Paging technique with the datagrid object and with the select command in Sql, thus forcing the server to only select those rows from the database that should be...
2
by: m.k.ball | last post by:
Thanks Rich - that's great. Before I found this group, I thought I had a reasonable understanding of SQL (well, MySQL's implementation of it, at least) but the truth is there are great chunks that...
6
by: ojorus | last post by:
Hi! My company make several flash-based games, and I use php to communicate with mysql to provide highscore-lists. My problem is this: When I save a player's score in the mysql-table, I want to...
5
by: davehansen22 | last post by:
Is there a way to generate a MySQL WHERE clause from a search string like this: "(dave OR hansen) php programmer" I would want to use the generated MySQL clause against a "memo" type field. ...
6
Atli
by: Atli | last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users. Anyone should be able to get...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.