473,231 Members | 2,041 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,231 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 2821
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...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
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: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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...

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.