?
Solved

Net::mysql module and inserting data into the table

Posted on 2003-03-08
2
Medium Priority
?
182 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 26

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
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

765 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