Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Net::mysql module and inserting data into the table

Posted on 2003-03-08
2
Medium Priority
?
189 Views
Last Modified: 2010-03-05
Hi gurus


I try to insert to MySQL database data using variables:

$mysql->query(q{
     INSERT INTO perltest (first, second, third) VALUES ("$first", "$second", "$third") });

But this doesn't work ??!!

So how can I use variables for inserting data to yhe database ??


Thanks advance.

-js
0
Comment
Question by:salmjuh
2 Comments
 
LVL 27

Accepted Solution

by:
wilcoxon earned 375 total points
ID: 8096226
Try this instead:

$mysql->query("insert into perltest (first, second, third) values ('$first', '$second', '$third')");

Have you considered using DBI and DBD::mysql?  If using DBI, it would be:

$dbh->do("insert into perltest (first, second, third) values ('$first', '$second', '$third')");

or

$dbh->do("insert into perltest (first, second, third) values (" . $dbh->quote($first) . ', ' . $dbh->quote($second) . ', ' . $dbh->quote($third) . ')');
0
 
LVL 20

Expert Comment

by:jmcg
ID: 9697669
Nothing has happened on this question in over 7 months. It's time for cleanup!

My recommendation, which I will post in the Cleanup topic area, is to
accept answer by wilcoxon.

Please post any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question