473,661 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DBD::Pg problem

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
"<su*****@somed omain.com>": can't parse "<su*****@somed omain.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

Nov 12 '05 #1
10 2912
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
"<su*****@somed omain.com>": can't parse "<su*****@somed omain.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
--
Martijn van Oosterhout <kl*****@svana. org> http://svana.org/kleptog/ "All that is needed for the forces of evil to triumph is for enough good
men to do nothing." - Edmond Burke
"The penalty good people pay for not being interested in politics is to be
governed by people worse than themselves." - Plato


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE/zYgKY5Twig3Ge+Y RArVDAJ0YqO4Ua0 jeiLz0xyYPLU74y qcoiQCdHq2G
pTH9QrMtdFGDdpY j3DpixAI=
=KGnB
-----END PGP SIGNATURE-----

Nov 12 '05 #2
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(),'$p arent')";
$sth = $dbh->prepare($sql );
$sth->bind_param(1 , $from, {pg_type => DBD::Pg::PG_TEX T});
$sth->bind_param(2 , $to, {pg_type => DBD::Pg::PG_TEX T});
$sth->bind_param(3 , $subject, {pg_type => DBD::Pg::PG_TEX T});
$sth->execute;

\d it_contact;
Table "public.it_cont act"
Column | Type |
Modifiers
------------+-----------------------------+-----------------------------
---------------------------------------
contact_id | integer | not null default
nextval('public .it_contact_con tact_id_seq'::t ext)
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: pg************* ****@postgresql .org
[mailto:pg****** ***********@pos tgresql.org] On Behalf Of Martijn van
Oosterhout
Sent: Wednesday, December 03, 2003 3:52 PM
To: Ausrack Webmaster
Cc: pg***********@p ostgresql.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
"<su*****@somed omain.com>": can't parse "<su*****@somed omain.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
--
Martijn van Oosterhout <kl*****@svana. org> http://svana.org/kleptog/ "All that is needed for the forces of evil to triumph is for enough
good men to do nothing." - Edmond Burke "The penalty good people pay
for not being interested in politics is to be governed by people worse than themselves." - Plato


---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 12 '05 #3
Ausrack Webmaster wrote:
The thing is...I am not. I am inserting it into a varchar field.


Are there any single quotes in the message body? They will wreak havoc
with the rest of the query. And why are you putting single quotes around
'$parent'?

What happens if you move the '$body' to the end:

$sql="insert into it_contact (email, to_email,
subject,modify, parent,details) values(?,?,?,no w(),$parent,'$b ody')";

Alex
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 12 '05 #4

Tried that ...it is definetely the to_email field, not any others that
is causing
the problem.

Jason
-----Original Message-----
From: pg************* ****@postgresql .org
[mailto:pg****** ***********@pos tgresql.org] On Behalf Of Alex Satrapa
Sent: Wednesday, December 03, 2003 6:31 PM
To: Ausrack Webmaster
Cc: pg***********@p ostgresql.org
Subject: Re: [GENERAL] DBD::Pg problem
Ausrack Webmaster wrote:
The thing is...I am not. I am inserting it into a varchar field.


Are there any single quotes in the message body? They will wreak havoc
with the rest of the query. And why are you putting single quotes around

'$parent'?

What happens if you move the '$body' to the end:

$sql="insert into it_contact (email, to_email,
subject,modify, parent,details) values(?,?,?,no w(),$parent,'$b ody')";

Alex
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if
your
joining column's datatypes do not match

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 12 '05 #5
On Wednesday 03 December 2003 09:43, Ausrack Webmaster wrote:
Tried that ...it is definetely the to_email field, not any others that
is causing
the problem.


With the table schema you gave, the following seems to work fine for me. Only
changes from your example are to remove quoting on $parent and let
bind_param() sort out types by itself.
#!/usr/bin/perl -w

use DBI;

$dbh = DBI->connect("dbi:P g:dbname=DBNAME HERE", "", "");

do_ins('alpha', 'beta','Blah1') ;
do_ins('d**@arc honet.com','d** @archonet.com', 'Blah2');
do_ins('<de*@ar chonet.com>','d **@archonet.com ','Blah3');
do_ins('<de*@ar chonet.com>','< de*@archonet.co m>','Blah4');

$dbh->disconnect;
exit;

sub do_ins {
my ($from,$to,$sub ject) = @_;
my $body = 'BBB';
my $parent = 0;

print STDERR "Trying f/t = $from / $to\n";
$sql="insert into it_contact (email, to_email, subject,
details,modify, parent) values(?,?,?,'$ body',now(),$pa rent)";
$sth = $dbh->prepare($sql );
$sth->bind_param(1 , $from);
$sth->bind_param(2 , $to);
$sth->bind_param(3 , $subject);
$sth->execute;
print STDERR "Ending f/t = $from / $to\n\n";
}

--
Richard Huxton
Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 12 '05 #6

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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
"<su*****@somed omain.com>": can't parse "<su*****@somed omain.com>"


Try a $dbh->trace(1) and see if that gives you any additional
information. Perhaps $parent is being inadvertantly set to a
string inside of the application?

- --
Greg Sabino Mullane gr**@turnstep.c om
PGP Key: 0x14964AC8 200312030733

-----BEGIN PGP SIGNATURE-----

iD8DBQE/zdiRvJuQZxSWSsg RAu0RAJ4/b9QmzZs7/w9n/Ta58Ba6ZqffHQCg/mSm
l/qPB/RNfyhtXeRKEQksQ wg=
=CXfi
-----END PGP SIGNATURE-----

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)

Nov 12 '05 #7
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,"','".$subj ect."','".$body ."', now(),'".$paren t."')";

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(),'$p arent')";
$sth = $dbh->prepare($sql );
$sth->bind_param(1 , $from, {pg_type => DBD::Pg::PG_TEX T});
$sth->bind_param(2 , $to, {pg_type => DBD::Pg::PG_TEX T});
$sth->bind_param(3 , $subject, {pg_type => DBD::Pg::PG_TEX T});
$sth->execute;

\d it_contact;
Table "public.it_cont act"
Column | Type |
Modifiers
------------+-----------------------------+-----------------------------
---------------------------------------
contact_id | integer | not null default
nextval('public .it_contact_con tact_id_seq'::t ext)
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: pg************* ****@postgresql .org
[mailto:pg****** ***********@pos tgresql.org] On Behalf Of Martijn van
Oosterhout
Sent: Wednesday, December 03, 2003 3:52 PM
To: Ausrack Webmaster
Cc: pg***********@p ostgresql.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
"<su*****@som edomain.com>": can't parse "<su*****@somed omain.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.
----
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 12 '05 #8
Barbara Lindsey <bl******@cog.u fl.edu> writes:
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,"','".$subj ect."','".$body ."',
now(),'".$paren t."')";

Then you dont have to bind params. You can just prepare and execute.
If you do this in production (rather than just for debugging) you may
be vulnerable to an SQL injection attack...
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.


....but it is useful for debugging.

-Doug

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 12 '05 #9
In article <3F************ **@cog.ufl.edu> ,
Barbara Lindsey <bl******@cog.u fl.edu> writes:
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,"','".$subj ect."','".$body ."', now(),'".$paren t."')"; Then you dont have to bind params. You can just prepare and execute.


.... and get interesting results if one of the variables contains
quotes or backslashes.

I often use something like that:

$dbh->do (q{
INSERT INTO it_contact (email, to_email, subject, details, modify, parent)
VALUES (?, ?, ?, ?, ?, ?)
}, undef, $from, $to, $subject, $body, now(), $parent);

This lets DBI do the proper quoting for you.
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 12 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3001
by: Pablo S | last post by:
Hi there mod_perl/Pg folks, I have 2 systems, one OLD, (linux 2.4 running postgresql-7.2.1-5 with a perl web db on Apache/1.3.23 mod_perl 1.26 and dbi 1.37 with peristent db connections via apache:dbi. ) The other system is NEW, which i am demoing (running the same web app on linux 2.6 postgresql-7.4.2-1 w/ Apache/2.0.49 & mod_perl/1.99_12 & apache:dbi. (this one fedora core
1
2453
by: Tim Nelson | last post by:
**** Post for FREE via your newsreader at post.usenet.com **** I am a newbie try to port my applications to Postgres. I have an application that is bulk loading a table with autocommit off (with it on it's way to slow). The logic of the application dictates that I try the insert, and if it fails because of a duplicate, update the record instead. The entire bulk load is wrapped in a transaction for speed purposes. When I hit a...
0
4657
by: Piotr B. | last post by:
Hello, I want to make use of a Perl script "ora2pg" (Oracle to PostgreSQL schema converter), which requires the following modules: DBI, DBD::Oracle and DBD::Pg. As I don't use Perl on a regular basis, I've downloaded and installed ActivePerl 5.6.1.638 (Windows). Then, I installed DBI and DBD::Oracle using the PPM utility. But, unfortunately, I couldn't install DBD::Pg:
0
2384
by: Envex Developments | last post by:
Hey guys, I have a need to install the DBD::Pg Perl module on many shared web servers, which do not have PostgreSQL installed. Then the DBD::Pg module will just connect to a remote PostgreSQL database, hosted elsewhere. I'm having some problems doing this. First off, I modified the Makefile.PL, and added the three following links just above the check for environment variables:
0
2298
by: Envex Developments | last post by:
Hey guys, I have a need to install the DBD::Pg Perl module on many shared web servers, which do not have PostgreSQL installed. Then the DBD::Pg module will just connect to a remote PostgreSQL database, hosted elsewhere. I'm having some problems doing this. First off, I modified the Makefile.PL, and added the three following links just above the check for environment variables:
0
1141
by: Alex | last post by:
Hi, I am using DBD::Pg in some of my scripts. I want to customize the error login based on the error received. While I am happy with the Errstr message I want to take specific actions depending on Errstr or Err. Is there a list of all available error number (err) with associated error message (errstr) that is produced by postgres? Is there something similar for JDBC ?
11
2317
by: greg | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 A new version of DBD::Pg is about to be released (1.32), and we need your help to test it out. If you use DBD::Pg, please download and test the latest release candidate. At the very least, running "make test" and reporting any problems would be of great help. The latest version can be found here:
4
1371
by: Patrick Hatcher | last post by:
Pg: 7.4.2 I use perl scripts to import data into my db. When errors occurred uploading files in Pg ver 7.3.x, $DBI::errstr used to return a row number from the input file. I could then go to the file make whatever changes and continue. Since updating to 7.4.2, I no longer receive this information. I now have to go to psql and run the import and only then will I see the error row. Is there a newer version than 1.32 of DBD::Pg? TIA
2
3016
by: David Siebert | last post by:
Anyone using Activestate Perl and DBD-Pg? I am using perl 5.8.3 ppm does not seem to work. I downloaded the DBD-Pg ..zip file I found through google but ppm could not seem to install that. Any suggestions? ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
0
8432
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8758
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6185
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5653
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4179
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4346
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1986
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.