Re: DBD::Pg problem

From: Barbara Lindsey <blindsey(at)cog(dot)ufl(dot)edu>
To: Ausrack Webmaster <webmaster(at)ausrack(dot)com(dot)au>
Cc: "'Martijn van Oosterhout'" <kleptog(at)svana(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: DBD::Pg problem
Date: 2003-12-03 13:25:11
Message-ID: 3FCDE437.9060309@cog.ufl.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

When I have problems like this, I do something like this:
$sql="insert into it_contact (email, to_email,
subject,details,modify,parent) values(
'".$from."','".$to,"','".$subject."','".$body."', now(),'".$parent."')";

Then you dont have to bind params. You can just prepare and execute.

Besides that, you can print the $sql string with the expanded variables
and copy and paste it into psql to see if that gets you a different
error to help debug if it is not already obvious when you see the whole SQL.

Hope this helps.
Barb

usrack Webmaster wrote:
> The thing is...I am not. I am inserting it into a varchar field.
>
> $sql="insert into it_contact (email, to_email, subject,
> details,modify,parent) values(?,?,?,'$body',now(),'$parent')";
> $sth = $dbh->prepare($sql);
> $sth->bind_param(1, $from, {pg_type => DBD::Pg::PG_TEXT});
> $sth->bind_param(2, $to, {pg_type => DBD::Pg::PG_TEXT});
> $sth->bind_param(3, $subject, {pg_type => DBD::Pg::PG_TEXT});
> $sth->execute;
>
> \d it_contact;
> Table "public.it_contact"
> Column | Type |
> Modifiers
> ------------+-----------------------------+-----------------------------
> ---------------------------------------
> contact_id | integer | not null default
> nextval('public.it_contact_contact_id_seq'::text)
> email | character varying(100) |
> to_email | character varying(100) |
> subject | text |
> fname | character varying(30) |
> lname | character varying(30) |
> kafname | character varying(30) |
> kalname | character varying(30) |
> details | text |
> modify | timestamp without time zone |
> status | smallint |
> parent | integer |
>
>
> Jason
>
> -----Original Message-----
> From: pgsql-general-owner(at)postgresql(dot)org
> [mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Martijn van
> Oosterhout
> Sent: Wednesday, December 03, 2003 3:52 PM
> To: Ausrack Webmaster
> Cc: pgsql-general(at)postgresql(dot)org
> Subject: Re: [GENERAL] DBD::Pg problem
>
>
> pg_atoi is the string to int converter. You're trying to insert it into
> an integer field.
>
> On Wed, Dec 03, 2003 at 03:45:53PM +0900, Ausrack Webmaster wrote:
>
>>Hi
>>
>>I am trying to insert a simple email address into a text field,
>>and I get the below error:
>>
>>DBD::Pg::st execute failed: ERROR: pg_atoi: error in
>>"<support(at)somedomain(dot)com>": can't parse "<support(at)somedomain(dot)com>"
>>
>>I figure it is because of the < and @ in the value, but why does it
>>take these as operators even when the value has single quotes around
>>it? I have even tried binding the values and PG_TEXT beforehand and
>>still not luck.
>>
>>Any help would be greatly appreciated.
>>
>>Jason Frisch
>>
>>
>>
>>---------------------------(end of
>>broadcast)---------------------------
>>TIP 4: Don't 'kill -9' the postmaster
>
>

--
Barbara E. Lindsey,
COG RDC
Phone: (352) 392-5198 ext. 314 Fax: (352) 392-8162

----
CONFIDENTIALITY NOTICE: The information contained in this electronic
message is legally privileged and confidential and intended only for the
use of the individual(s) or entity(ies) named above. If the reader of
this message is not the intended recipient, you are hereby notified that
any dissemination, distribution, or copying of this email or any of it's
components is strictly prohibited. If you have received this email in
error, please contact the sender.
----

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John Sidney-Woollett 2003-12-03 13:34:30 Re: Transaction Question
Previous Message Alvar Freude 2003-12-03 13:23:27 Re: Cast text to bytea: the Solution