You are here: Re: using heredoc for SQL statements « PHP Programming Language « IT news, forums, messages
Re: using heredoc for SQL statements

Posted by Oli Filth on 09/25/60 11:37

Tom said the following on 17/01/2006 03:27:
> I've used heredocs for single SQL statements without a problem. Also,
> I've tried this using the SQL form on PhpMyAdmin and it works so I
> conclude it should work in PHP.
>
> Problem: getting syntax error with following SQL statement:
>
> $_sql = <<<SQLDOC
> LOCK TABLES `table_name` WRITE;
> INSERT INTO `table_name` ('col_a', 'col_b') VALUES ('value_a1',
> 'value_a2');
> INSERT INTO `table_name` ('col_a', 'col_b') VALUES ('value_b1',
> 'value_b2');
> UNLOCK TABLES;
> SQLDOC;
>
> Error Message:
>
> "You have an error in your SQL syntax; check the manual that
> corresponds to your MySQL server version for the right syntax to use
> near '; INSERT INTO `table_name`..."
>

mysql_query() doesn't support multiple SQL statements separated by
semi-colons. You'll either need to separate your statements into
separate mysql_query() calls, or use the mysqli_multi_query() statement,
if it's available.

--
Oli

 

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

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