Uutiset:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu
Advertisement:

Fixing a code snippet

Aloittaja Keydet, joulukuu 20, 2013, 08:25:10 IP

« edellinen - seuraava »

Keydet

Hello, I'm adding an item to SMFShop. I'd ask for help over there, but it's basic enough and that forum is rarely viewed.

I am trying to just get this item to write to the database when I use it, currently goes to a blank white screen when I try to.

The first three id's are values that the database assigned the item, so I just pulled those. user_id needs to pull the member's id from the forum, but I'm not sure if it's doing that. Points spent should be 0, and the purchase date should be on use.

The database is called la_items_purchased.

Thank you in advance!

function onUse()
{
global $db_prefix, $ID_MEMBER;


db_query("INSERT INTO {items_purchased} (item_id, pack_id, group_id, user_id, points_spent, purchase_date)
    VALUES (329, 7, 19, '{$ID_MEMBER}', 0, " . TIME_NOW . ")");

    return 'Youve successfully equipped the Broom! Enjoy!';
}

margarett

You should try to use $smcFunc instead. There are several examples (in SMF code itself) on how to use it to insert.

Plus, if you want to submit your MOD to our modsite we will ask you to use it :P
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

LainaaOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

emanuele

Considering what is in global Keydet is probably using SMF 1.1, so margarett he cannot use $smcFunc. ;)

The first thing I see wrong is the name of the table:

db_query("INSERT INTO {items_purchased}

I guess you wanted to write:

db_query("INSERT INTO {$db_prefix}items_purchased


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Advertisement: