l i n u x - u s e r s - g r o u p - o f - d a v i s
Next Meeting:
October 20: Web Application Hacking: How to Make and Break Security on the Web
Next Installfest:
Latest News:
Oct. 10: LUGOD Installfests coming again soon
Page last updated:
2004 Dec 23 13:12

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] sqlite + perl - wierd unrecognized token error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] sqlite + perl - wierd unrecognized token error

On Thu 23 Dec 04, 11:15 AM, Shwaine <shwaine@shwaine.com> said:
> On Thu, 23 Dec 2004, Peter Jay Salzman wrote:
> <snip>
> >  DBD::SQLite::db do failed: unrecognized token: ":" at Create_Tables.pm 
> >  line
> >  52, <> line 6.
> >
> <snip>
> >Excerpt from Create_Tables.pm:
> >
> <snip>
> >     my $dbh = DBI->connect("dbi:SQLite:$table_name");
> >
> <snip>
> >Statement handle DBI::st=HASH(0x840773c) DESTROY ignored - never set up
> >       ERROR: 1 'unrecognized token: ":"' (err#0)
> In my MySQL connections, I have database=$table_name, not just 
> $table_name. That is a driver specific syntax though, so you may want to 
> check the documentation for your specific driver to see if that is the 
> syntax it expects.

The alternate syntax (database=$tablename) didn't generate any errors, so at
least the dbi driver for sqlite understood it.  Unfortunately, it still
gives the same unrecognized token error.

> Another thing I did when debugging a program was to put 
> the SQL command in a string, print the string, then pass the string to do. 
> Then I could see exactly what was passed to do.

DOH!!!  Now why didn't *I* think of that?!?

Grade Utility
1. Create a new class
2. Add a student
3. Modify a record
4. Print_Record()
5. Dump_All_Records
q. Quit

Choice: 1
Enter semester: qwer
Enter course: asdf
Enter Course Desc: zxc
Enter college: ve
Enter reference: sadf

      INSERT INTO course VALUES (
           DBI::db=HASH(0x83f16fc)->quote ( qwer ),
           DBI::db=HASH(0x83f16fc)->quote ( asdf ),
           DBI::db=HASH(0x83f16fc)->quote ( zxc ),
           DBI::db=HASH(0x83f16fc)->quote ( ve ),
           DBI::db=HASH(0x83f16fc)->quote ( sadf )
DBD::SQLite::db do failed: unrecognized token: ":" at Create_Tables.pm line 74, <> line 6.
Uncaught exception from user code:
        DBD::SQLite::db do failed: unrecognized token: ":" at Create_Tables.pm line 74, <> line 6.
        Create_Tables::Create_Database('HASH(0x835dcd8)') called at ./driver.pl line 66
        main::Create_Course() called at ./driver.pl line 30
        main::main_menu() called at ./driver.pl line 73

Looks like

   $dbh->quote( blah )

isn't executing the quote method.  I think the problem is that I'm calling
the method inside a double quote:

      INSERT INTO course VALUES (
         $dbh->quote ( $course->{semester} ),
         $dbh->quote ( $course->{course} ),
         $dbh->quote ( $course->{course_desc} ),
         $dbh->quote ( $course->{college} ),
         $dbh->quote ( $course->{reference} )

so I think I want this, instead (or something equivalent):

      INSERT INTO course VALUES ( " .
         $dbh->quote ( $course->{semester} )    . ", " .
         $dbh->quote ( $course->{course} )      . ", " .
         $dbh->quote ( $course->{course_desc} ) . ", " .
         $dbh->quote ( $course->{college} )     . ", " .
         $dbh->quote ( $course->{reference} )


The mathematics of physics has become ever more abstract, rather than more
complicated.  The mind of God appears to be abstract but not complicated.
He also appears to like group theory.  --  Tony Zee's "Fearful Symmetry"

GPG Fingerprint: B9F1 6CF3 47C4 7CD8 D33E  70A9 A3B9 1945 67EA 951D
vox-tech mailing list

LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Appahost Applications
For a significant contribution towards our projector, and a generous donation to allow us to continue meeting at the Davis Library.