You are here: Re: quote smart fails with null string « PHP Programming Language « IT news, forums, messages
Re: quote smart fails with null string

Posted by bill on 12/24/06 12:39

Tim Van Wassenhove wrote:
> bill schreef:
>> from: http://us3.php.net/mysql_real_escape_string
>>
>> // Quote variable to make safe
>> function quote_smart($value)
>> {
>> // Stripslashes
>> if (get_magic_quotes_gpc()) {
>> $value = stripslashes($value);
>> }
>> // Quote if not a number or a numeric string
>> if (!is_numeric($value)) {
>> $value = "'" . mysql_real_escape_string($value) . "'";
>> }
>> return $value;
>> }
>>
>> However when I pass it a null string it returns just a single double
>> quote.
>> It would be easy to fix, but I don't understand why it does this.
>
> All mysql_real_escape_string does is replace characters... Since php
> will replace NULL with an empty string, the mysql_real_escape_string
> returns an empty string.. .So value becomes the concatenation of ',
> empty string and '.
>
> I think your confusion comes from the fact that $value = "NULL" and
> $value = null both mean different things.... And on top of that in a SQL
> query "NULL" and NULL mean different things too....
>
>
>
Actually, my eyes were failing. I read '' as ". It was working
fine.

bill

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация