Some Php Coding

Status
Not open for further replies.
Skilled Illusionist
Joined
Jan 7, 2009
Messages
322
Reaction score
15
Ehm if someone Nice person out there who could make this work , its from my Voting Panel and it dont send the items to the post box so could anyone make it send to the invintory ? :tongue:

Code:
<?php

class Spend
{

    function __construct()
    {
        $Realm = addslashes($_POST['realm']);
        $Character = addslashes($_POST['character']);
        $Reward = addslashes($_POST['reward']);
        $Con = mysql_connect(MYSQL_HOST,MYSQL_USER,MYSQL_PASS);
        mysql_select_db(MYSQL_DB);
        
        //check availability of reward.
        $res = mysql_query("SELECT itemid,points FROM voterewards WHERE id='{$Reward}' AND realm='{$Realm}'");
        if(!$Rinfo = mysql_fetch_array($res))
            die("Nonexistant reward or realm.");
            
        
        // check points available
        if((int)$Rinfo['points'] > (int)$_SESSION['vcp']['points'])
            die("Insufficient points.");
            
        //get realm info
        $res = mysql_query("SELECT sqlhost,sqluser,sqlpass,chardb FROM realms WHERE id='{$Realm}'");
        $Realminfo = mysql_fetch_array($res);
        mysql_close($Con);
        
        // deduct points
        $Con = mysql_connect(LOGON_HOST,LOGON_USER,LOGON_PASS);
        mysql_select_db(LOGON_DB);
        mysql_query("UPDATE accounts SET reward_points = reward_points - {$Rinfo['points']} WHERE username='{$_SESSION['vcp']['account']}'");
        (int)$_SESSION['vcp']['points'] -= (int)$Rinfo['points'];
        mysql_close($Con);
        
        //send item.
        $Con = mysql_connect($Realminfo['sqlhost'],$Realminfo['sqluser'],$Realminfo['sqlpass']);
        mysql_select_db($Realminfo['chardb']);
    
        
        mysql_query("INSERT INTO mails ( charID_from,charID_to,date_sent,hasBeenRead,title,message,penya,item_id,item_count ,item_addedByQuestID ) VALUES ( '{$Character}', '{$Character}', '".time()."', '0', 'Your order!', 'Here is your order!', '0', '{$Rinfo['itemid']}',  '1',  '-1');");
        
        mysql_close($Con);
        die("1");
    }
}


?>
 
mysql_query("INSERT INTO mails ( charID_from,charID_to,date_sent,hasBeenRead,title,message,penya,item_id,item_count ,item_addedByQuestID ) VALUES ( '{$Character}', '{$Character}', '".time()."', '0', 'Your order!', 'Here is your order!', '0', '{$Rinfo['itemid']}', '1', '-1');");

I think that part needs to be changed...
 
look. don't beg for people to do your work for you. you have an error in the sql file. thats all. why not brush up on your mysql commands and procedures?

BBim has pointed to a system that adds items into inventory. why not take a look at the part where the sql sends the items to the mailbox? Thats is what he was saying.

Its seems all you want to do is sit back and let people do the work for you. If you want to learn about PServer development then get involved more.
 
I cannot see any problem in the insert to mail's query,

Try this one, ive only added mysql_error() so that it will print out the error if it was one, also made the code readable:
Code:
mysql_query("INSERT INTO `mails` (`charID_from`,`charID_to`,`date_sent`,`hasBeenRead`,`title`,`message`,`penya`,`item_id`,`item_count`,`item_addedByQuestID`) VALUES
	('{$Character}','{$Character}','".time()."','0','Your order!','Here is your order!','0','{$Rinfo['itemid']}','1','-1');") or die("Error in \"INSERT TO `mails`\" query:<br>".mysql_error());

If this doesn't work and its an error in this SQL, there may be an error in the values, as in too long or anything like that, if so then wide up the field in the database so it can can handle it.
Just like every other bugs, the mails field may have one or more bugs where one or another field doesn't allow enough characters to accept the query.

- Myself Ive removed the mailbox because it has too many bugs. Users have lost items by mailing their own characters...
Try BBim's script that adds to an free inventory slot instead if you cannot get mail script to work.
 
Why does your script constantly connect and disconnect to the sql server. You only need to connect once then kill it at the end of the script.
 
Hi guys I need one code mysql for my page web for create user in my database automaticment please HELP MYYYYY!!!!! or one page for my server of flyff is what create user to hand is much work.
 
Luxury, is your friend :) Thats where i learnt to do most codes i couldnt solve by my self :) Just a suggestion
 
Status
Not open for further replies.
Back