RE: Postgres query failing, not enough info for debugging...

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

 



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

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