Solved

PHP - SQL LIKE problem

Posted on 2007-12-03
4
1,138 Views
Last Modified: 2013-12-12
I have an SQL statement that setup like this:

Tickets.Subject LIKE \"%value1%\"

I wish to change this so that it uses a variable called $data

Is this possible.
0
Comment
Question by:andyw27
  • 2
4 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20395864
Tickets.Subject LIKE \"%$data%\"
0
 
LVL 3

Accepted Solution

by:
cforant earned 500 total points
ID: 20395867
Tickets.Subject LIKE \"%" . $data . "%\"
0
 
LVL 3

Expert Comment

by:cforant
ID: 20395887
you should look something like this

$sql = "select * from table where tickets.subject like \"%" . $data . "%\";
or
$sql = "select * from table where tickets.subject like '%" . $data . "%'";


0
 

Author Closing Comment

by:andyw27
ID: 31412337
Thanks - that has worked great.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

867 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

19 Experts available now in Live!

Get 1:1 Help Now