Jump to content

Recommended Posts

What is the error in this?

 


function BuyMS($user, $wal, $type)
{
    $noNaquadah = "Not enough Naquadah!";
    $nosold = "Not enough untrained units!";
    if ($type == 0) {
        $pris = 350000000 * $wal;
        if ($pris <= ($user->gold)) {
            $q = @mysql_query("select Mothership from `UserDetails` where ID='$user->ID' ");
            $el = mysql_fetch_array($q, MYSQL_ASSOC);
            if ($el[] >= $wal) { // error on this line.
                $q = @mysql_query("update `UserDetails` set Mothership = 1, gold=gold-'$pris' where ID='$user->ID' ");
                if (!$q) {
                    print ('Query failed: ' . mysql_error());
                    return;
                }
            } else
                return $nosold;
        } else
            return $noNaquadah;
    }

    if ($cgi[buyMS]) {

        if ($cgi[Mothership]) {
            $wal = $cgi[Mothership];
            $typ = 0;
            $detail .= Mothership($user, $wal, $typ);
        }
    }
  

	{
	 //echo "--$typ--";
	header("Location: armory.php?strErr=$detail");

	}
}

Link to comment
https://forums.phpfreaks.com/topic/84500-cant-figure-out-the-error/
Share on other sites

There is no key used in the array on this line:

 

if ($el[] >= $wal) { // error on this line.

Since the only field you pull from the database is Mothership, i assume that was meant to be:

 

if ($el['Mothership'] >= $wal) { // error on this line.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.