Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^4: MySQL Table adding with Perl

by Corion (Pope)
on Mar 06, 2013 at 21:03 UTC ( #1022092=note: print w/ replies, xml ) Need Help??


in reply to Re^3: MySQL Table adding with Perl
in thread MySQL Table adding with Perl

If you use the following to connect to the database, DBI will tell you more about where things (maybe) go wrong:

my $connect = DBI->connect( "dbi:mysql:database=Champ;host=localhost", 'root','pass', { RaiseError => 1 }, );

This saves you adding the error checking in every situation.

A bit more advice - I like to read passwords from a separate file, or from %ENV or anywhere else. That way, I can't inadverently post the database password when posting (or printing) my script.


Comment on Re^4: MySQL Table adding with Perl
Select or Download Code
Re^5: MySQL Table adding with Perl
by Anonymous Monk on Mar 06, 2013 at 21:17 UTC

    Unfortunately with the addition of that line, there was no output. The scripts runs without error. Thanks Corion for the advice about the passwords, I will definitely keep that in mind.

      Your code cannot run at all:

      $maketable = ("CREATE TABLE $newuser (A,B,C,D,E)");

      This is not valid SQL (except maybe in SQLite). But that doesn't matter because you never run that statement.

      $sth = execute();

      This should never work. You need to call the ->execute() method on your statement handle. Unless you also have defined (but not shown to us) a subroutine with the name execute.

        After the change it is responding with errors. Sorry, beginner Perl programmer mistake. Thanks for the answer!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1022092]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (11)
As of 2014-10-22 23:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (122 votes), past polls