Solved

SQL Issue

Posted on 2014-03-03
3
238 Views
Last Modified: 2014-03-03
What is wrong with this query?

SELECT * from subcat_docs where prim = 'Polywrap' and category = '20' Perforations' and subcategory = 'Black 200/400''

When I run this phpMyadmin, it says error in the syntax near "where catag".

The attached shows the table structure.

Thanks
subcat-docs-str.jpg
0
Comment
Question by:Richard Korts
3 Comments
 
LVL 18

Accepted Solution

by:
Matthew Kelly earned 250 total points
ID: 39902009
Can you post the exact phpMyAdmin message?

I just made that table, and ran that query (copy and pasted) the below, and it ran without error.

SELECT * from subcat_docs where prim = 'Polywrap' and category = '20' Perforations' and subcategory = 'Black 200/400''

Open in new window

0
 

Author Comment

by:Richard Korts
ID: 39902105
That's crazy; I just ran it again, no error.

Can you tell we how to escape the data (from a MySQL point of view)  if there are ' in the data itself?

Thanks
0
 
LVL 35

Assisted Solution

by:Terry Woods
Terry Woods earned 250 total points
ID: 39902108
Just add a backslash before it eg
where word = 'can\'t'

Open in new window

You can often avoid escaping by using double quotes too.

When you're writing code to perform queries with user supplied data, you need to have foolproof methods to ensure any special characters get properly escaped, or your software can become vulnerable to SQL injection attack. Let me know if you want more information on this (it's language dependent).
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More Fun with XML and MySQL – Parsing Delimited String with a Single SQL Statement Are you ready for another of my SQL tidbits?  Hopefully so, as in this adventure, I will be covering a topic that comes up a lot which is parsing a comma (or other…
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikipedia.org/wiki/PHP  Very powerful.  But a…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now