SELECT LIKE with "%" and without "%"
SELECT LIKE with "%" and without "%"
am 03.05.2009 01:43:02 von Emiliano Boragina
SGVsbG8uDQoNCkkgYW0gdXNpbmcgdGhpczoNCiRzcWwgPSAiU0VMRUNUICog RlJPTSB0YWJsZSBX
SEVSRSBJRCBMSUtFICclJF9HRVRbaWRdJScgQU5EIHRpdGxlIExJS0UNCicl JF9HRVRbd29yZF0l
JyI7DQoNCkJ1dCBJIHdhbnQgZXhhY3RsdSBJRCwgbm90IG9uZSBwYXJ0IG9m IG1hbnkgcG9zc2li
bGVzIElkcyBpbiB0aGUgREIuDQpIb3cgY2FuIEkgZG8gdGhhdD8NCg0KVGhh bmtzDQoNCiugoKCg
oKCgoKCgoKCgoKAgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCg oKCgoKCgoKCgoKCg
oKCgoKCgoKCgoKCgIF8NCqCgIC8vIEVtaWxpYW5vIEJvcmFnaW5hIF8NCqCg IC8vIERpc2XxbyAm
IENvbXVuaWNhY2nzbiAvLy8vLy8vLy8vLy8vLy8vLy8NCiugoKCgoKCgoKCg oKCgoKAgoKCgoKCg
oKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCg oKCgoKCgIF8NCqCg
IC8vIGVtaWxpYW5vLmJvcmFnaW5hQGdtYWlsLmNvbaAgLw0KoKAgLy8gMTUg NDAgNTggNjAgMDIg
Ly8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vDQoroKCgoKCgoKCgoKCgoKCg IKCgoKCgoKCgoKCg
oKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCg oCBfDQo=
Re: SELECT LIKE with "%" and without "%"
am 03.05.2009 02:11:22 von muhsin
Emiliano Boragina wrote:
> Hello.
>
> I am using this:
> $sql = "SELECT * FROM table WHERE ID LIKE '%$_GET[id]%' AND title LIKE
> '%$_GET[word]%'";
>
This doesnt work?
$sql = "SELECT * FROM table WHERE ID='some_id' AND title='some_title';
--
Extra details:
OSS:Gentoo Linux
profile:x86
Hardware:msi geforce 8600GT asus p5k-se
location:/home/muhsin
language(s):C/C++,VB,VHDL,bash,PHP,SQL,HTML,CSS
Typo:40WPM
url:http://mambo-tech.net
url:http://blog.mambo-tech.net
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: SELECT LIKE with "%" and without "%"
am 04.05.2009 09:01:36 von Eleonora De Marinis
--------------080300010609060309050207
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
$sql = "SELECT * FROM table WHERE ID ='$_GET[id]' AND title LIKE
'%$_GET[word]%'";
-------- Original Message --------
Subject: [PHP-DB] SELECT LIKE with "%'" and without "%'"
From: Emiliano Boragina
To: php-db@lists.php.net
Date: 05/03/2009 01:43 AM
> 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?
>
> Thanks
>
> + _
> // Emiliano Boragina _
> // Diseño & Comunicación //////////////////
> + _
> // emiliano.boragina@gmail.com /
> // 15 40 58 60 02 ///////////////////////////
> + _
>
--------------080300010609060309050207--
Re: SELECT LIKE with "%" and without "%"
am 04.05.2009 15:30:37 von Philip Thompson
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:
$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
Re: SELECT LIKE with "%" and without "%"
am 24.02.2010 11:31:41 von Ahmet Caner
"Eleonora De Marinis" , haber iletisinde sunlari
yazdi:49FE92D0.2060406@garr.it...
> $sql = "SELECT * FROM table WHERE ID ='$_GET[id]' AND title LIKE
> '%$_GET[word]%'";
>
>
>
> -------- Original Message --------
> Subject: [PHP-DB] SELECT LIKE with "%'" and without "%'"
> From: Emiliano Boragina
> To: php-db@lists.php.net
> Date: 05/03/2009 01:43 AM
>> 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?
>>
>> Thanks
>>
>> +
>> _
>> // Emiliano Boragina _
>> // Diseño & Comunicación //////////////////
>> +
>> _
>> // emiliano.boragina@gmail.com /
>> // 15 40 58 60 02 ///////////////////////////
>> +
>> _
>>
>
>
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php