Thread: SQL insert help
View Single Post
  #1  
Old 11-27-2011, 03:58 AM
Ohk4y Ohk4y is offline
Registered User
Ohk4y's Avatar
Join Date: Jun 2011
Posts: 43
Ohk4y is an unknown quantity at this point
Send a message via AIM to Ohk4y
SQL insert help

Hello, I came across an error while trying to insert a row into a sqlite database, which the database is named 'loot'. I get an error outputted by sql in rc:
PHP Code:
SQL Error: constraint failed 
Here's the sql part of the script:

PHP Code:
function AddToLoot() {
  
temp.mineral = "SELECT content FROM inventories WHERE rowid="@this.itemm;
  
temp.account = player.account;
  
temp.classn = "mineral";
  
temp.name_en = temp.mineral;
  
temp.loc = this.level;
  
temp.x = this.x;
  
temp.y = this.y;
  
temp.query = "INSERT INTO loot (account, class, name_en, loc, x, y) VALUES ('"@temp.account@"', '"@temp.classn@"', '"@temp.name_en@"', '"@temp.loc@"', '"@temp.x@"', '"@temp.y@"')";
  
temp.requestObject = requestsql(temp.query, true);
    
  
this.waitfor(temp.requestObject, "onReceiveData", 30);
  
  if (
temp.requestObject.error) {
    echo(
"SQL Error: " @ temp.requestObject.error);
    return;
  }  
  
this.chat = temp.requestObject.lastinsertid;
} 
Anybody know what I did wrong?
__________________
Reply With Quote