Solved

PHP - SQL LIKE problem

Posted on 2007-12-03
4
1,137 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]
Comment Utility
Tickets.Subject LIKE \"%$data%\"
0
 
LVL 3

Accepted Solution

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

Expert Comment

by:cforant
Comment Utility
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
Comment Utility
Thanks - that has worked great.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

763 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