Re: To quote or not to quote?
| From: | no-spam----me at larrykagan dot com | Date: | Tue, 04 Feb 2003 02:41:54 +0000 |
| Subject: | Re: To quote or not to quote? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-25394@lists.php.net to get a copy of this message | ||
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