473,289 Members | 2,040 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,289 software developers and data experts.

Is 'finding' a MySQL keyword or such?

Hi there!

I'm using PHP to create a simple, dynamic MySQL SELECT query.

The user chooses a selection from a HTML Form SELECT element's many options
and submits the form via a POST action.

The SELECT query is built as follows:

$itemtype = stripslashes(trim($_POST['selType']));
$query = "select * from item where item_subtype like '%$itemtype%'";

I've used:
echo "<center><b>".$query."</b></center><br />";
to see that the queries are being properly constructed.

When the option with the value of 'finding' is chosen, no records are
displayed, although there are many records in the item_subtype field of the
item table that contain the string 'finding', such as 'Earring finding' and
'chandelier finding'.

The display of records works fine when other values are chosen (other than
the value of 'finding')

Help!

Can anybody help me figure out what might be preventing records with
'finding' in the item_subtype field from showing.

I have no problem with any other of the SELECT element's values being passed
to the query.

Here is the 'offending' query: select * from item where item_subtype like
'%finding%'

Thank you so very much, in advance, for your help!

Peace!

(by the way, I'm not sure if the peculiarity is due to a problem in MySQL or
PHP, so I've posted in this newsgroup)

Jun 15 '06 #1
2 2825
ElkGroveR wrote:
The SELECT query is built as follows:

$itemtype = stripslashes(trim($_POST['selType']));
$query = "select * from item where item_subtype like '%$itemtype%'";

I've used:
echo "<center><b>".$query."</b></center><br />";
to see that the queries are being properly constructed.

When the option with the value of 'finding' is chosen, no records are
displayed, although there are many records in the item_subtype field of the
item table that contain the string 'finding', such as 'Earring finding' and
'chandelier finding'.

The display of records works fine when other values are chosen (other than
the value of 'finding')

Help!

Can anybody help me figure out what might be preventing records with
'finding' in the item_subtype field from showing.

I have no problem with any other of the SELECT element's values being passed
to the query.

Here is the 'offending' query: select * from item where item_subtype like
'%finding%'


'finding' is not a reserved word.

A few thoughts:

- the % in %finding% might be implemented so that at least one
character is mandatory for each %-placeholder, so that 'Earring
finding' is not found (on MySQL 4.0 this isn't the case though).
- case sensitive
- non-matching characters that look the same/similar (different
charcode)
- spaces at start/end of $itemtype in form value (PS the actual value
is passed from the form, not its corresponding text that user sees in
<option>s-list on screen)
- typing error in 'finding'

I think you can better use the following syntax:

SELECT * FROM item WHERE item_subtype REGEXP 'finding'

Hope this helps,

--
Bart

Jun 15 '06 #2
Hi Bart

Thanks for your reply.

I want the SELECT query to retrieve records that contain 'finding' (or any
option element value) whether it is found at the beginning, middle or end of
the value in the item_subtype field, so the % works in that context - it
works for any other option element value - any value except 'finding'.

I will look into using REGEXP, especially when users enter search data /
keywords themselves.

Peace!

John

"Bart Van der Donck" <ba**@nijlen.com> wrote in message
news:11**********************@y41g2000cwy.googlegr oups.com...
ElkGroveR wrote:
The SELECT query is built as follows:

$itemtype = stripslashes(trim($_POST['selType']));
$query = "select * from item where item_subtype like '%$itemtype%'";

I've used:
echo "<center><b>".$query."</b></center><br />";
to see that the queries are being properly constructed.

When the option with the value of 'finding' is chosen, no records are
displayed, although there are many records in the item_subtype field of
the
item table that contain the string 'finding', such as 'Earring finding'
and
'chandelier finding'.

The display of records works fine when other values are chosen (other
than
the value of 'finding')

Help!

Can anybody help me figure out what might be preventing records with
'finding' in the item_subtype field from showing.

I have no problem with any other of the SELECT element's values being
passed
to the query.

Here is the 'offending' query: select * from item where item_subtype like
'%finding%'


'finding' is not a reserved word.

A few thoughts:

- the % in %finding% might be implemented so that at least one
character is mandatory for each %-placeholder, so that 'Earring
finding' is not found (on MySQL 4.0 this isn't the case though).
- case sensitive
- non-matching characters that look the same/similar (different
charcode)
- spaces at start/end of $itemtype in form value (PS the actual value
is passed from the form, not its corresponding text that user sees in
<option>s-list on screen)
- typing error in 'finding'

I think you can better use the following syntax:

SELECT * FROM item WHERE item_subtype REGEXP 'finding'

Hope this helps,

--
Bart

Jun 15 '06 #3

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

Similar topics

2
by: Phil Powell | last post by:
Relevancy scores are normally defined by a MySQL query on a table that has a fulltext index. The rules for relevancy scoring will exclude certain words due to their being too short (minimum...
0
by: Phil Powell | last post by:
The table already has a fulltext index and from there I can use the MySQL fulltext search query to get results as well as the relevancy score. The problem I have is that MySQL has a default...
4
by: Hal Halloway | last post by:
can mysql work in Windows but not Solaris? Is there any reason you can see why the fulltext php/mysql code below works OK on my win2k php4.3.6. mysql 4.1.3 pc but does *not* work when put on a...
10
by: Python_it | last post by:
Python 2.4 MySQL-python.exe-1.2.0.win32-py2.4.zip How can I insert a NULL value in a table (MySQL-database). I can't set a var to NULL? Or is there a other possibility? My var must be variable...
0
by: odysseyphotography | last post by:
Hi, I'm trying to build a simple search for a database of jobs. Users can search using three groups of critera: 1) Area (check boxes) Buying and merchandising Design Executive
2
by: Extremest | last post by:
Here is the code I have so far. It connects to a db and grabs headers. It then sorts them into groups and then puts all the complete ones into another table. Problem I am having is that for some...
0
by: Harshpandya | last post by:
Hi I am using MYSQL and ASP.Net. to build the Data Reader Page. when i define my connection Key - it gives me this error.Keyword not supported: 'dsn'. MY PAGE Data Reader <%@ Page Language="C#"...
30
by: Einstein30000 | last post by:
Hi, in one of my php-scripts is the following query (with an already open db-connection): $q = "INSERT INTO main (name, img, descr, from, size, format, cat, host, link, date) VALUES ('$name',...
12
by: Jeff | last post by:
As I'm learning PHP, I'm making a fair number of mistakes in syntax. In perl, you can turn on reading these errors from the browser by adding this: use CGI::Carp 'fatalsToBrowser'; Is there...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.