Re: SELECT LIKE with "%" and without "%"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On May 2, 2009, at 6:43 PM, Emiliano Boragina wrote:

Hello.

I am using this:
$sql = "SELECT * FROM table WHERE ID LIKE '%$_GET[id]%' AND title LIKE
'%$_GET[word]%'";

But I want exactlu ID, not one part of many possibles Ids in the DB.
How can I do that?

PLEASE tell me your cleaning that input...

http://php.net/mysql_real_escape_string

And to answer your question:

<?php
$id = mysql_real_escape_string ($_GET['id']);
$word = mysql_real_escape_string ($_GET['word']);

$sql = "SELECT * FROM `table` WHERE `ID` = '$id' AND `title` = '$word'";
?>

Read more on MySQL's "LIKE" functionality. Google can help you.

HTH,
~Philip

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux