Re: Hyphens and MySQL
| From: | Martin Norland | Date: | Fri, 28 Jan 2005 15:16:59 +0000 |
| Subject: | Re: Hyphens and MySQL | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-38376@lists.php.net to get a copy of this message | ||
Mark Benson wrote:
I am having problems with entering data into MySQL from a PHP script. I am taking the data from an array generated by a CSV parsing routine. That in itself works great, however I have large number of data units with '-' characters in (hyphens) and it is causing the SQL queries to dump out with an error in the syntax. I can't get around it by putting a slash in front of them (using 'addcslashes'), it will just not at all accept them. Are they the 'wrong' type of slash? Is there an easy way to search and replace/remove characters in a string in PHP? If you're quoting these values, you should be having no problem.e.g. INSERT into TABLE_FOO (colname) values ('-'); but this will error: INSERT into TABLE_FOO (colname) values (-); Cheers, -- - Martin Norland, Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital.