Hello, im new in this forum for the first time i want to say HELLO.
I have little problem with my website/webshop and refund items, the problem is this:

If player try to sold back for the first time appear this error:
Warning: mssql_fetch_array(): supplied argument is not a valid MS SQL-result resource inC:\AppServ\www\modules\refund.php on line 63

and in line 63 is this:
$res = mssql_fetch_array(mssql_query($query));

and item cannot be refund

if i remove function for verify if item dissappear from vault script work give credits but item no dissappear from inventory.

BUT attention after first time script work, give credits and delete items from dissappear

this is my code:

Código PHP:
<?php
//ini_set('display_errors',1);//ini_set('display_startup_errors',1);//error_reporting(-1);
iseedeadpeople();switch (1) {    default:     if ($webshop['credits']['sellback_Q']<=0) {        print phrase_blocked_module;        break;    }    if (strlen($_GET['serial'])!=8) {        print '<span class="alert">Invalid or missing item parameter.</span>';        break;    }    $query    mssql_query("select * from [WebShop_UI] where substring([item],7,8)='".secure($_GET['serial'])."'");    $result    mssql_fetch_array($query);    $result['credits']    = round($result['credits']*$webshop['credits']['sellback_Q']);    if ($result['credits']<1) {        print '<span class="alert">You are not allowed to resell that item.</span>';        break;    }    if ($result['memb___id']!= $GLOBALS['mu_user']) {    print '<span class="alert">You are not allowed to resell that item.</span>';        break;    }    $query    mssql_query("select [connectstat] from ".$webshop['mssq']['dbacc'].".dbo.[MEMB_STAT] where [memb___id]='".$GLOBALS['mu_user']."'");    $res1    mssql_fetch_row($query);    if ($res1[0]!=0) {        print phrase_offline_rq;        break;    }    $query    mssql_query("select [AccountId] from [warehouse] where (charindex (0x".$_GET['serial'].", Items) %16=4)");    $rez    mssql_fetch_row($query);    if ($rez[0]!=$GLOBALS['mu_user']) {        print '<span class="alert">Item not found. Please put the item in your warehouse.</span>';        break;    }    require './inc/function.iteminfo.php';    $item    ItemInfo($result['item']);    if ($item['refund']!=1) {        print '<span class="alert">That item cannot be soldout.</span>';        break;    }    print '<span class="succes">Your item will now be replaced.';    $newitem"0x".$result['item'];    $query    "    declare @it varbinary(3840),    @it1 varbinary(16),    @it2 varbinary(16),    @it3 int;    set @it     = (select [items] from [warehouse] where [accountid]='".$GLOBALS['mu_user']."');    set @it1     = ".$newitem.";    set @it3    = 0;    while (@it3<121) BEGIN        set @it2 = substring(@it,16*@it3+1,16);        if (@it1 = @it2) BEGIN            select @it3 as 'marked';            set @it3 = 120;        END        set @it3 = @it3+1;    END    ";    $res    mssql_fetch_array(mssql_query($query));    mssql_query("declare @items varbinary(3840);     set @items = (select [items] from [warehouse] where [AccountId]='".$GLOBALS['mu_user']."');     print @items;");    $ci     mssql_get_last_message();        mssql_query("update [warehouse] set [items]=".substr_replace($ci'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'$res[0]*32+232)." where [AccountId]='".$GLOBALS['mu_user']."' and [items]=".$ci."");         $query22    mssql_query("select [AccountId] from [warehouse] where (charindex (0x".$_GET['serial'].", Items) %16=4)");    $rez22    mssql_fetch_row($query22);          if ($rez22[0]!=$GLOBALS['mu_user']) {    mssql_query("delete from [WebShop_UI] where substring([item],7,8)='".secure($_GET['serial'])."'");    shoplog($GLOBALS['mu_user']." has soldback an item with serial <a href=\"index.php?sy=search&item_serial=".$_GET['serial']."\">".$_GET['serial']."</a> for ".$result['credits']." credits");    mssql_query("exec XCredits '".$GLOBALS['mu_user']."',".$result['credits'].";");    } else {    print '    <span class="alert">'.phrase_resell_error.'.</span>';    shoplog($GLOBALS['mu_user']." try to soldback but have error <a href=\"index.php?sy=search&item_serial=".$_GET['serial']."\">".$_GET['serial']."</a>");    }        print 'Success!<br>You have earned <b>'.$result['credits'].'</b> credits for selling out <span style="color:'.$item['color'].'; background-color: #000">'.$item['name'].'</span></span>';
}
?>
please take a look

please take a look