dartsuresh has asked for the wisdom of the Perl Monks concerning the following question:

we have domain search script in perl this script call from php using exec() command .when call the perl script from php with some domain name and userid then perl script crawl the domain detail and insert into mysql table .table names are domain,host so its working .problem is when 2 user search same time perl script insert insert some data of 1 user to 2 user detail viceversa here my code
use warnings; use Getopt::Std; use URI; use LWP::UserAgent; use HTTP::Request; use Yahoo::Search; use Net::Whois::Raw; use Net::DNS; use HTML::LinkExtractor; use Try::Tiny; use XML::Simple; use XML::DOM; use XML::XPath; use XML::XPath::XMLParser; use URI::Escape; use MIME::Base64; use Digest::HMAC_SHA1 qw(hmac_sha1); use Data::Dumper; use Siteminer; use CGI; use threads; # # Global Variables # # my %DEBUG = ( "addDomain" => 1, "getWhois" => 1, "domainOwner" => 1, "netcraftMine" => 1, "yahooMine" => 1, "intTLDSearch" => 1, "alexaRank" => 1, "hostMine" => 1, "yahooLinks" => 1, "bingMine" => 1, "pageRank" => 1, "pullData" => 1, "addHostname" => 1, ); # # Amazon AWIS Account Keys # my $AWIS_ACCESS_KEY_ID = "XXXXXXXXXXXXXXXXXXx"; my $AWIS_SECRET_ACCESS_KEY = "XXXXXXXXXXXXXXXXXXx"; my $AWIS_SERVICE_ENDPOINT = "XXXXXXXXXXXXXXXXXXx"; my $AWIS_ACTION = "XXXXXXXXXXXXXXXXXXx"; # # command line arguements # #chomp($name = param("uid")); my %opts = (); getopts('hvd:', \%opts) || usage(); my $user_id= $ARGV[0]; my $owner_email = ""; $Net::Whois::Raw::OMIT_MSG = 1; # # Main # main(); #my $thr1=threads->create(\&main); sub main { # # Check arguments # usage() if ($opts{h} || ! $opts{d}); # # check if domain name is valid # if (! domainNameIsValid(DOMAIN=>$opts{d})) { print STDERR "\nError: Domain Name invalid (example: foo.com)\ +n"; usage(); } $owner_email = addDomain(DOMAIN=>$opts{d}, ORIGIN=>$opts{d}) || "" +; netcraftMine(DOMAIN=>$opts{d}); # # Search Yahoo (Deprecated) # #yahooMine(DOMAIN=>$opts{d}); while(my @hostnames = Siteminer::Hosts->search('done' => '0')) { hostMine(HOSTS=>\@hostnames, ORIGIN=>$opts{d}); bingMine(HOSTS=>\@hostnames, ORIGIN=>$opts{d}); } while(my @domains = Siteminer::Domains->search('done' => '0', 'own +er' => $opts{d})) { foreach my $obj (@domains) { my $domain = $obj->domain; print "DO: $domain\n"; netcraftMine(DOMAIN=>$domain); # # Yahoo (Deprecated) # #yahooMine(DOMAIN=>$domain); while(my @hostnames = Siteminer::Hosts->search('done' => ' +0')) { hostMine(HOSTS=>\@hostnames, ORIGIN=>$opts{d}); bingMine(HOSTS=>\@hostnames, ORIGIN=>$opts{d}); } $obj->done(1); $obj->update; } } }

siteminer.pm

package Siteminer::DBI; use base 'Class::DBI'; # Setup connection to database Siteminer::DBI->connection('dbi:mysql:database', 'username', 'password +'); package Siteminer::Hosts; use base 'Siteminer::DBI'; __PACKAGE__->table('hosts'); __PACKAGE__->columns( All => ( "id", "hostname", "ipaddress", "webcode", "webbanner", "webtitle", "sslcode", "sslbanner", "ssltitle", "done", "redirect", "origin", "yweblinks", "alexarank", "pr", "login", "loginuserid", ) ); package Siteminer::Domains; use base 'Siteminer::DBI'; __PACKAGE__->table('domains'); __PACKAGE__->columns( All => ( "id", "domain", "email", "whois", "server", "origin", "owner", "done", "loginuserid", ) );

Replies are listed 'Best First'.
Re: how can Multiple Insert in Perl to mysql with php
by moritz (Cardinal) on Feb 24, 2012 at 06:15 UTC

    I'm sure the problem is in line 42 of your script. Oh, wait...

    Since you haven't provided any useful details nor any code, we can't tell you what's wrong. But on a general note, if you need to make multiple insertions into a database safe against multi tasking, you should wrap them in a common transaction. DBI has support for transactions, and mysql has too, if you use InnoDB as the storage engine.

Re: how can Multiple Insert in Perl to mysql with php
by CountZero (Bishop) on Feb 24, 2012 at 06:14 UTC
    Sorry, the batteries of my crystal ball have just run out.

    How can we answer this question if no code at all is shown?

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

    My blog: Imperial Deltronics
Re: how can Multiple Insert in Perl to mysql with php
by stevieb (Canon) on Feb 24, 2012 at 06:30 UTC
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: how can Multiple Insert in Perl to mysql with php
by Riales (Hermit) on Feb 24, 2012 at 07:22 UTC

    It's hard to say for sure, but I'd guess the problem lies somewhere in the Siteminer module. Do you have the code for that as well?

    Edit: Ok, I was wrong about the problem being in the Siteminer module. Hmm...what module is exporting the bingMine, netcraftMine functions? I can't figure out where you're inserting data back into any tables.