Posted by mun on 03/19/07 06:41
On Mar 19, 6:04 am, Toby A Inkster <usenet200...@tobyinkster.co.uk>
wrote:
> 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!
I am sorry for my late reply. I will try the function and let you know.
[Back to original message]
|