Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Q&A

Quests::Q&A This is the quest support section

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-08-2012, 02:55 AM
blackdragonsdg
Dragon
 
Join Date: Dec 2008
Location: Tennessee
Posts: 656
Default Fetching item id's

Need a bit of help with this script. I want to take a list of item names from a text file then fetch there associated item id's from the database then output both the item names and item id's into a specific format as indicated below.


Code:
use DBI;
my $db = "peq";
my $user = "root";
my $pass = "password";
my $host = "localhost";
my $source = "DBI:mysql:database=$db;host=$host";
my $dbh = DBI->connect($source, $user, $pass) || die "Could not create db handle\n";

sub get_item {
my $item_name;
my $item_id;
    my $sth = $dbh->prepare("SELECT * FROM items WHERE `name`=$item_name and `id`=$item_id");
    $sth->execute();

########Something along the lines of fetch() is suppose to go here
########not sure what though
}

open (FILE, 'data.txt');
while (<FILE>) {
	chomp;

########take item name from file pass it through get_item() retrieving item id
########then take the item name and the fetched item id
########outputting it into the desired format

	open (MYFILE2, '>>data2.txt');
	print MYFILE2 "INSERT INTO `lootdrop_entries` (`lootdrop_id`, `item_id`, `item_charges`, `equip_item`, `chance`) VALUES (x, $id, 1, 0, z);	/* $name */\n";
 }
close (MYFILE);
close (MYFILE2);
Reply With Quote
 


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 On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 01:51 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3