Click here to get back home

PHP MySQL Query

 HomeNewsGroups | Search | About
 comp.lang.php    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
PHP MySQL Query john doe 07-18-2008
Get Chitika Premium
Posted by john doe on July 18, 2008, 5:02 pm
Please log in for more thread options
Hi All,

I have the following query that works great...

$result = mysql_query("SELECT * FROM location WHERE location_tag LIKE
'A___'")
or die(mysql_error());

I'm currently trying to change it over to something like..

$result = mysql_query("SELECT * FROM location WHERE location_tag LIKE
'$letter___'")
or die(mysql_error());

but I can't get the " escaping right!

Any tips would be grand =)

JD

Posted by john doe on July 18, 2008, 5:06 pm
Please log in for more thread options
john doe wrote:
> Hi All,
>
> I have the following query that works great...
>
> $result = mysql_query("SELECT * FROM location WHERE location_tag LIKE
> 'A___'")
> or die(mysql_error());
>
> I'm currently trying to change it over to something like..
>
> $result = mysql_query("SELECT * FROM location WHERE location_tag LIKE
> '$letter___'")
> or die(mysql_error());
>
> but I can't get the " escaping right!
>
> Any tips would be grand =)
>
> JD

Aha, solved it myself.

For anyone searching I did this..

$result = mysql_query("SELECT * FROM location WHERE location_tag LIKE
'".$letter."___'")

On a side note, can anyone see anything I could maybe do better? I'm
searching the DB for codes in the form X123, as an example.

JD

Posted by Paul Lautman on July 18, 2008, 5:30 pm
Please log in for more thread options
john doe wrote:
> john doe wrote:
>> Hi All,
>>
>> I have the following query that works great...
>>
>> $result = mysql_query("SELECT * FROM location WHERE location_tag LIKE
>> 'A___'")
>> or die(mysql_error());
>>
>> I'm currently trying to change it over to something like..
>>
>> $result = mysql_query("SELECT * FROM location WHERE location_tag LIKE
>> '$letter___'")
>> or die(mysql_error());
>>
>> but I can't get the " escaping right!
>>
>> Any tips would be grand =)
>>
>> JD
>
> Aha, solved it myself.
>
> For anyone searching I did this..
>
> $result = mysql_query("SELECT * FROM location WHERE location_tag LIKE
> '".$letter."___'")
>
> On a side note, can anyone see anything I could maybe do better? I'm
> searching the DB for codes in the form X123, as an example.
>
> JD

Or try:
$result = mysql_query("SELECT * FROM location WHERE location_tag LIKE
'___'")
or die(mysql_error());



Posted by john doe on July 19, 2008, 8:12 am
Please log in for more thread options
Paul Lautman wrote:
> john doe wrote:
>> john doe wrote:
>>> Hi All,
>>>
>>> I have the following query that works great...
>>>
>>> $result = mysql_query("SELECT * FROM location WHERE location_tag LIKE
>>> 'A___'")
>>> or die(mysql_error());
>>>
>>> I'm currently trying to change it over to something like..
>>>
>>> $result = mysql_query("SELECT * FROM location WHERE location_tag LIKE
>>> '$letter___'")
>>> or die(mysql_error());
>>>
>>> but I can't get the " escaping right!
>>>
>>> Any tips would be grand =)
>>>
>>> JD
>> Aha, solved it myself.
>>
>> For anyone searching I did this..
>>
>> $result = mysql_query("SELECT * FROM location WHERE location_tag LIKE
>> '".$letter."___'")
>>
>> On a side note, can anyone see anything I could maybe do better? I'm
>> searching the DB for codes in the form X123, as an example.
>>
>> JD
>
> Or try:
> $result = mysql_query("SELECT * FROM location WHERE location_tag LIKE
> '___'")
> or die(mysql_error());
>
>
Ahh, much neater! Cheers!

Similar ThreadsPosted
PHP saying error in mysql syntax, but written my mysql query browser! March 21, 2007, 7:25 pm
Hot to use one mysql query in a second mysql query July 18, 2004, 4:52 am
MySQL Query August 29, 2005, 11:24 am
Mysql Query November 2, 2005, 2:50 am
Help with Mysql query November 22, 2005, 5:11 pm
MySQL Query August 26, 2006, 1:07 pm
mysql query in PHP October 6, 2006, 6:49 am
[SQL] need help on a mysql query November 21, 2007, 11:06 am
MySQL JOIN Query--help August 12, 2004, 6:57 am
Using PHP, But have a MySql Query Problem August 24, 2004, 9:44 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap