Re: To quote or not to quote?

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

 



Unknown Sender <bogus@news.php.net> wrote:
As mentioned in another reply, in MySQL all fields can have quotes regardelss of
type.  If you really need to tell, use this:

if(!is_numeric($value)) {
   $value = "'" . $value . "'"; 
}

> I guess this is mostly a MySQL question, but perhaps PHP has a solution...

> I would like a foolproof way to determine whether a data value needs to be
> quoted.  Numeric data doesn't need quotes, but string data does.

> I could use mysql_field_type and check if it's integer, float, double,
> real, etc., but this seems fragile.  I could easily miss one, or a new
> version of MySQL could add a new one.

> So how can I get the equivalent of a "mysql_needs_quotes" function?

> --
> Patrick Doyle
> doylep@eecg.utoronto.ca


-- 
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