You are here: Re: my_real_escape_string problem « PHP Programming Language « IT news, forums, messages
Re: my_real_escape_string problem

Posted by Toby A Inkster on 03/18/07 23:04

mun wrote:

> function quote_smart($value)
> {
> // Stripslashes
> if (get_magic_quotes_gpc()) {
> $value = stripslashes($value);
> }
> // Quote if not integer
> if (!is_numeric($value)) {
> $value = " ' " . mysql_real_escape_string($value) . " ' ";
> }
> return $value;
> }

Code defensively...

function quote_smart ($value)
{
if (is_numeric($value))
return $value;

if (get_magic_quotes_gpc())
$value = stripslashes($value);

if (function_exists('mysql_real_escape_string'))
return mysql_real_escape_string($value);

trigger_error("mysql_real_escape_string function does not exist!");
return addslashes($value);
}

Does that work OK? Try it a few times. Now check your PHP error log and
see if a surprise message awaits!

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!

 

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

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