Solved

PHP - SQL LIKE problem

Posted on 2007-12-03
4
1,144 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 143

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

749 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