Thread: do I have a reserved word here or something???

do I have a reserved word here or something???

From
Jeremy Hansen
Date:
INSERT into env_info
(username,useremail,servicelevel,accountmanager,company) values
('$env_array{User}','$env_array{UserEmail}','$env_array{ServiceLevel}'
,'$env_array{AccountManager}','$env_array{Company}'

I sometime get a parse error near username, but for the life of me, can't
figure out what my issues is...mainly because it "sometimes" works.
Username example that failed is:

eds_bv3

Any clues as to why this insert would fail?

Thanks for all the help!
-jeremy

--
salad.


Re: do I have a reserved word here or something???

From
"Peter Haworth"
Date:
On Tue, 14 Aug 2001 12:25:54 -0400 (EDT), Jeremy Hansen wrote:
>
> INSERT into env_info
> (username,useremail,servicelevel,accountmanager,company) values
> ('$env_array{User}','$env_array{UserEmail}','$env_array{ServiceLevel}'
> ,'$env_array{AccountManager}','$env_array{Company}'
>
> I sometime get a parse error near username, but for the life of me, can't
> figure out what my issues is...mainly because it "sometimes" works.

It's probably because you're not correctly quoting your values. I suspect that
the ones which fail contain single quotes in one or more of the values.
Assuming you're using the DBI, do one of the following, preferably the first
one:

1.
  $dbh->do(q(
    insert into env_info
      (username,useremail,servicelevel,accountmanager,company)
    values(?,?,?,?,?)
  ),{},@env_array{qw(User UserEmail ServiceLevel AccountManager Company)});
2.
  my($uname,$email,$level,$mgr,$company)=map $dbh->quote($_),
    @env_array{qw(User UserEmail ServiceLevel AccountManager Company)};
  $dbh->do(qq(
    insert into env_info
      (username,useremail,servicelevel,accountmanager,company)
    values($uname,$email,$level,$mgr,$company)
  ));

--
    Peter Haworth    pmh@edison.ioppublishing.com
"When you say `I wrote a program that crashed Windows', people just stare
 at you blankly and say `Hey, I got those with the system, *for free*'"
        -- Linus Torvalds

Re: do I have a reserved word here or something???

From
Jeremy Hansen
Date:
On Wed, 15 Aug 2001, Peter Haworth wrote:

> On Tue, 14 Aug 2001 12:25:54 -0400 (EDT), Jeremy Hansen wrote:
> >
> > INSERT into env_info
> > (username,useremail,servicelevel,accountmanager,company) values
> > ('$env_array{User}','$env_array{UserEmail}','$env_array{ServiceLevel}'
> > ,'$env_array{AccountManager}','$env_array{Company}'
> >
> > I sometime get a parse error near username, but for the life of me, can't
> > figure out what my issues is...mainly because it "sometimes" works.
>
> It's probably because you're not correctly quoting your values. I suspect that
> the ones which fail contain single quotes in one or more of the values.
> Assuming you're using the DBI, do one of the following, preferably the first
> one:
>
> 1.
>   $dbh->do(q(
>     insert into env_info
>       (username,useremail,servicelevel,accountmanager,company)
>     values(?,?,?,?,?)
>   ),{},@env_array{qw(User UserEmail ServiceLevel AccountManager Company)});

Perfect.  This is working so far.  Thank You!

-jeremy

> 2.
>   my($uname,$email,$level,$mgr,$company)=map $dbh->quote($_),
>     @env_array{qw(User UserEmail ServiceLevel AccountManager Company)};
>   $dbh->do(qq(
>     insert into env_info
>       (username,useremail,servicelevel,accountmanager,company)
>     values($uname,$email,$level,$mgr,$company)
>   ));
>
>

--
salad.