Home  |  Linux  | Mysql  | PHP  | XML
From:Ford, Mike Date:Wed Jun 17 10:39:28 2009
Subject:RE: Postgres query failing, not enough info for debugging...
On 16 June 2009 15:57, Carol Walter advised:

> Hello,
>
> I'm using PHP 5 and PostgreSQL 8.3.6. I have a query that is failing
> and I don't know how to troubleshoot the problem. The error message
> that it is giving is quite vague. The error message is as follows:
>
>
> Warning: pg_query_params() [function.pg-query-params]: Query failed:
> ERROR: syntax error at end of input at character 156 in /home/walterc/
> ssl/PHP/km_input_test2c.php on line 631
> ERROR: syntax error at end of input at character 156
>
> The query that is failing looks like this...
>
> $pg_pres_ins6 = pg_query_params("INSERT INTO \"brdgMediaCallsEvents
> \" (\"mediumId\", \"eventId\", rank) VALUES
> ((currval('\"tblMedia_mediumId_seq\"'),
> (currval('\"tblCallsEvents_eventId_seq\"'), $1)", array($ev_rank));
> echo pg_last_error($pg_connection);

You have 2 more opening parentheses than close parentheses in that SQL
-- in both cases, the parenthesis immediately preceding currval should
be omitted.

Also, to ameliorate your quote hell, you might consider using a heredoc
(http://php.net/manual/language.types.string.php#language.types.string.s
yntax.heredoc) for this:

$pg_pres_ins6 = pg_query_params(<<<SQL
INSERT INTO "brdgMediaCallsEvents" ("mediumId", "eventId", rank)
VALUES (currval('"tblMedia_mediumId_seq"'),
currval('"tblCallsEvents_eventId_seq"'), $1)
SQL
, array($ev_rank));

Cheers!

Mike

--
Mike Ford, Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus,
Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom
Email: m.ford@leedsmet.ac.uk
Tel: +44 113 812 4730


To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm
Navigate in group php.db at sever news.php.net
Previous Next


Your recent visits
What is SAPI?
Rounding up results
Re: Cannot connect to MySQL
Re: [PHP-DB] Upgrading PHP Version 5.1.6
Storing images



  
© No Copyright
You are free to use Anything, but please consult your advocate before doing so as this website
also list content from other sources which may be copyrighted.
Site Maintained by Zareef Ahmed
Powered By PHP Consultants