  | 
	
	
	
		Kyote Novice
 
  Joined: 13 Jan 2002 Posts: 36 Location: USA
  | 
		
		  
			
			   Posted: Thu Jan 20, 2005 7:03 am   
  Adding a record in a DB?   | 
			 
			
				This is just something simple to help me keep track of a few money makers on my mud.
 
Here's the trigger:
 
 
#TRIGGER {You get (%d) silver coins and (%d) gold coins from the corpse of (*).} {#if (%2 > 1000) {#VAR MMaker "";#ADDKEY MMaker {Name = %3};#ADDKEY MMaker {Gold = %2};#NEW GoldMakers @MMaker;#SHOWDB @MMaker}} "MyDB"
 
 
Okay, now here's the output after passing through my trigger(actually from prompt to promt):
 
 
<3547/3547hp 2021/2938m 1539/1539mv 479> 
 
A magic missile flies from your hand and hits a medium sized fish in the chest.
 
Your magic missile inflicts UNSPEAKABLE PAIN to a medium sized fish! (538)
 
A medium sized fish is DEAD!!
 
You receive 218 experience points.
 
A medium sized fish spills her guts all over the floor.
 
You get 264866 silver coins and 2881 gold coins from the corpse of a medium sized fish.
 
Name :  a medium sized fish
 
Gold :  2881
 
 
The Gods give you 50 gold coins for your sacrifice.
 
 
<3547/3547hp 1912/2938m 1539/1539mv 261> 
 
 
And here's the resulting variable
 
 
#VAR MMaker {Name  a medium sized fishGold  2881}
 
 
That's from me exporting and cut-n-pasting. My database is called GoldMakers and it has 2 columns Name=text and Gold=Number.
 
When the above executes it makes a blank record with only the Gold column filled with a 0. Name is blank. I am leaving the DB open as i do this. Sorry, I don't mean to babble, can anyone tell me what I'm doing wrong here? TIA | 
			 
		  | 
	
	
	  
		  
		    
			  _________________ ------------
 
Kyote.sends("Greetings") | 
			       | 
			 
		   
		 | 
	
	
		  | 
	
	
		LightBulb MASTER
 
  Joined: 28 Nov 2000 Posts: 4817 Location: USA
  | 
		
		  
			
			   Posted: Thu Jan 20, 2005 12:49 pm      | 
			 
			
				You are using the "keyname=value" form of #ADDKEY, but you are adding spaces before and after the = symbol. These spaces are included in the variable, and as a result your keynames don't match the database field names. "Name " doesn't match "Name", and "Gold " doesn't match "Gold". As a result, your #NEW record doesn't include any data for the actual fields and you get their default values instead. The default value of a text field is an empty string and the default value of a number field is 0.
 
 
To fix this, either remove the spaces or use the {keyname} {value} form of #ADDKEY.
 
#ADDKEY MMaker {Name=%3};#ADDKEY MMaker Gold {%2} | 
			 
		  | 
	
	
	  
		  
		    
			  _________________ LightBulb
 
Senior member
 
 
Most scripts in this forum are written for Command Line entry. 
 
Don't even open the Settings Editor unless its use is specified or obvious. | 
			       | 
			 
		   
		 | 
	
	
		  | 
	
	
		| 
		
		 | 
	
	
		 |