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 01-28-2013, 01:01 AM
SavageDeath
Fire Beetle
 
Join Date: Jan 2013
Location: In the USA
Posts: 15
Default Question about Perl Query via DBI

Alright so I know this has been asked a few times before but I'm new to this so please put up with me for a bit =)

My question is how can I get Perl to pull a value from a custom table via a query? I can get it to insert new values and such into the new table I made easy enough but getting it to pull a numerical value is where I have no clue what to do. I have seen the other posts where you guys were using a fetch to pull the values, but how would I get the NPC to tell me what those values are in a say or how could I get the script to use those values as a check ?

Here is what I have.

Code:
sub EVENT_SAY {
	
	if($text=~/Hail/i)
	{
		use DBI;
		use DBD::mysql;
		$tablename = "test";
		my $connect = DBConnect();
			# Create the Query
		$query = "INSERT INTO $tablename (id, name, description, value) VALUES('$charid', '$name', 'test', 20)";
		$query_handle = $connect->prepare($query);
		$query_handle->execute();
		$connect->disconnect();		
	}
	
		if($text=~/try/i)
		{
		use DBI;
		use DBD::mysql;
		my $connect = DBConnect();
		
		$query = "SELECT value FROM test WHERE id = $charid";

		$query_handle = $connect->prepare($query);
		$query_handle->execute();
		##I'm not sure how to get it to push out what I want in a quest say here, pretty sure I need a fetch of some sort.
		$connect->disconnect();
		}
}
It connects and inserts a new value when I hail the NPC which is great. But I want to be able to pull the value from the value column and use it as a check. Or to tell the player oh yeah you have x amount of value in storage or whatever.

I know I can do this with globals but I rather not I was hoping to use a completely different table for it.

Any help would be greatly appreciated, if you could post an example or point me in the right direction that would be great, thanks in advance!


Note: I am aware I'm not showing where I have the database info to connect, figured that wasn't need for you guys to help. I made a sub routine for it to connect just a heads up.
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 07:05 PM.


 

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 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3