LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-04-2012, 01:14 AM   #1
zak100
Member
 
Registered: Jul 2009
Posts: 225

Rep: Reputation: 2
storing complete email address in mysql using perl


Hi,
I am trying to store complete email address in mysql db, but its not storing '@' symbol. Kindly guide me. I am working on Fedora 10.
My perl code is as follows:

Code:
#!/usr/bin/perl
use DBI;
$dbh=DBI->connect('dbi:mysql:perltest','root','')
or die "connection error : dbi:: errstr\n";
$username="ssuet2";
$email="ssuet2@edu.pk";


$sql="insert into subcribers(username, emailaddr) values ('$username','$email')";
$th=$dbh->prepare($sql);
$th->execute
or die "SQL Error: $DBI::errstr\n";

$username="ssuet3";
$email="ssuet3@edu.pk";


$sql="insert into subcribers(username, emailaddr) values ('$username','$email')";
$th=$dbh->prepare($sql);
$th->execute
or die "SQL Error: $DBI::errstr\n";
The ouput of mysql is:
Code:
mysql> select * from subcribers;
+-----+----------+-----------+
| uid | username | emailaddr |
+-----+----------+-----------+
|   1 | ssuet1   | ssuet1.pk | 
|   2 | ssuet2   | ssuet2.pk | 
|   3 | ssuet3   | ssuet3.pk | 
+-----+----------+-----------+
3 rows in set (0.00 sec)

mysql>
Somebody plz guide me with this problem.

Zulfi.
 
Old 10-04-2012, 05:10 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,294

Rep: Reputation: 2347Reputation: 2347Reputation: 2347Reputation: 2347Reputation: 2347Reputation: 2347Reputation: 2347Reputation: 2347Reputation: 2347Reputation: 2347Reputation: 2347
I'm a little surprised you didn't get an error there... anyway, first I recommend using best practice and amending the top of your prog thus
Code:
#!/usr/bin/perl -w
use DBI;
use strict;
then externally use
Code:
perl -wc myperl.pl
and fix any errors and warnings displayed.

Secondly, look at the paragraph here that mentions '$dbh->quote($string) method' http://www.perlmonks.org/?node_id=162771
See also http://search.cpan.org/~timb/DBI/DBI.pm
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Kmail and auto complete of email address in the TO field shazam75 Linux - Software 3 08-14-2013 12:17 PM
Disabling Thunderbird email address auto complete wastingtime Linux - Software 1 12-19-2010 03:13 AM
Perl: Storing Cart-Like items in Mysql without CGI::Session zachet Programming 5 03-11-2010 11:29 AM
storing values in an array in perl script :) kdelover Programming 5 09-16-2009 06:01 PM
sending an email to a email address after a perl operation meluser Programming 9 04-07-2003 01:26 PM


All times are GMT -5. The time now is 10:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration