Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: mySQL with Perl

by stephen (Priest)
on Mar 05, 2002 at 23:00 UTC ( #149542=note: print w/replies, xml ) Need Help??

in reply to mySQL with Perl

To find out if your username exists in the database, you need to make a SELECT query to the database asking for any records with $username in them.

I would suggest that you read some of the tutorials here on DBI:

(I'm refraining from answering the question directly because I believe you'll find learning the answer from the tutorials more rewarding in the long term.) :)

I would also suggest that you look into using placeholders in your query. Right now, you're interpolating the strings '$username' etc. into your insert statement. While this will work most of the time, someone could enter "T'Pau" as a username, and your insertion statement would be:

...Values ('T'Pau'...
which would then be a database error, since the quotation would end after the T. At very least, I'd change it to the following:
$query = qq(insert into members (username, password, email, name, url, + date) Values (?, ?, ?, ?, ?, ?)); $sth = $dbh->prepare($query); $sth->execute($username, $password, $email, $name, $url, $time) or die + "Error in execution: $DBI::errstr";
You can learn more about this in the abovementioned tutorials.


Update: Added explanation of indirect answer.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://149542]
[atcroft]: stevieb: I have berrybrew installed on a Win machine, and I noticed that with perlbrew you can "upgrade" a particular installed version... any chance of doing something similar in the
[atcroft]: future with berrybrew?
[atcroft]: stevieb: Also, one other odd question... is it possible to set it up so that all the versions installed can use a single directory that they pull module sources into, rather than duplicating files? (Am I making sense, or do I have too high a CBC
[atcroft]: (caffeine-blood content) atm?)
[atcroft]: .oO(Interesting... I just went to http://blogs.perl. org/, did a search for "Mars", and tried to go to the second page of results, and received instead a "Request-URI Too Large" message.... odd.)

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2017-04-29 05:14 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (531 votes). Check out past polls.