Re: Weird SQL Problem

From: Michael Glaesemann <grzm(at)myrealbox(dot)com>
To: <operationsengineer1(at)yahoo(dot)com> <operationsengineer1(at)yahoo(dot)com>
Cc: PostgreSQL Novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Weird SQL Problem
Date: 2005-09-11 10:59:12
Message-ID: 0BAED329-0CD0-4BD0-87F9-0D925EC15C4B@myrealbox.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


On Sep 9, 2005, at 7:03 AM, <operationsengineer1(at)yahoo(dot)com>
<operationsengineer1(at)yahoo(dot)com> wrote:

> $sql_insert = <<<_EOSQL
>
> INSERT INTO t_customer (customer_name,
> customer_entry_date)
> VALUES (?,?)
>
> _EOSQL;
>
> $result = $db->Execute($sql_insert,
> array($customer_name, CURRENT_TIMESTAMP));
>
> does using a heredoc preclude me from being able to
> bind variables to parameters or have i found another
> novel (to me, anyway!) way to jack my code up?

To PHP, the result of heredoc, single-quotes, or double-quotes is
just a string, so I can't think of why heredoc should have anything
to do with it. What does jump out at me is that you're using
CURRENT_TIMESTAMP outside of the string. The bare word
CURRENT_TIMESTAMP only has meaning in SQL, i.e., the SQL string
passed back to database server. Here you're using it in a PHP array,
which I'm guessing PHP is trying to interpret as a constant, and one
that's probably undefined. I'd put it in query itself. Bind variables
are for just that: variables, i.e., things that change.

Besides what appears in the browser, be sure to check your logs as
well. I keep Apache's error log open all the time when I'm coding, as
there are often errors that don't manifest themselves in the browser.

As an aside, I haven't used ADOdb's variable binding before, so I
don't know how well it compares with Perl DBI's, which does the right
thing with strings automatically (no need to escape the string). I'll
have to look into it more. If it *does*, that would be really nice.

Michael Glaesemann
grzm myrealbox com

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Pradeepkumar, Pyatalo (IE10) 2005-09-12 03:00:23 Re: Please help - libpq API
Previous Message Luciano 2005-09-11 04:46:35 I can't put the password in anyone program