Unsupported Operand Types In / - What this =?

free web hosting
Free Web Hosting > Computers & Tech > Programming > Scripting > PHP

Unsupported Operand Types In / - What this =?

Feelay
Hey!

Can anyone try to help me find what I've made wrong =? I keep getting this error (Fatal error: Unsupported operand types in /home/feelay/public_html/attackck.php on line 49)
But I can't find what I've made wrong =/

Here is the code:

CODE
<?php
session_start();

include "database.php";

############################################################


    function attack(){
#Line 10        
        #Ge $dbQueryHealth ett värde
        $atkuser= mysql_real_escape_string($_POST['atkuser']);
$querythe =("SELECT temphealth FROM characters WHERE user='$atkuser'")or die(mysql_error());    
        #Sätt $currentHealth med värdet från databas-resursen $dbQuery
        if(mysql_num_rows(mysql_query($querythe)) == 1)
    {
        $currentHealthEnemy = mysql_fetch_assoc(mysql_query($querythe));
        }else{ die("User Don't Excist. Please Go Back And Try Again");}
#Line 20                             
            

$nuser=mysql_real_escape_string($_SESSION['user']);
$auser=mysql_real_escape_string($_SESSION['admin']);

if($nuser){
$userfinal=$nuser;
}elseif($auser){
$userfinal=$auser;
#Line 30
}
        ####################################################
$querythy ="SELECT temphealth FROM characters WHERE user='$userfinal'"or die(mysql_error());

        
        #Sätt $currentHealth med värdet från databas-resursen $dbQuery
        $currentHealthYou = mysql_result(mysql_query($querythy),0)or die(mysql_error());  
#Line 40
  
        
       $minHealth = 0;
       $maxHealth = 100;
       $expAward = mt_rand (1, 300);
       $healthAward = mt_rand (1, 30);
       $winner= mt_rand (0, 1);


#Line 50
    if($winner) {
            if(($currentHealthEnemy - $healthAward) > $minHealth) {  
                $currentHealthEnemy -= $healthAward;
                #$currentExp + expAward;
                echo "You won! The enemy now have {$currentHealthEnemy} HP.";  




/*Line 60 */






            } else {


#Line 70              
  echo "You won! You Killed The Enemy";
                $currentHealthEnemy = $maxHealth;
                #$currentExp + expAward;
            }
        } else {
            if(($currentHealthYou - $healthAward) <= 0) {
                echo "You Lost. The Enemy killed you.";
                $currentHealthYou = 100;
            } else {
#Line 80        $currentHealthYou -= $healthAward;
                echo "You lost! You've lost {$healthAward} HP. You now have {$currentHealthYou} HP.";
            }  
        }

$nuser=mysql_real_escape_string($_SESSION['user']);
$auser=mysql_real_escape_string($_SESSION['admin']);

if($nuser){
#Line 90
$userfinal=$nuser;
}elseif($auser){
$userfinal=$auser;
}    
$SeUs = $userfinal;
$PoUS = mysql_real_escape_string($_POST['atkuser']);
$result = mysql_query("UPDATE characters SET temphealth='$currentHealthYou' WHERE user='$SeUs'")
or die(mysql_error());
#Line 100

$result = mysql_query("UPDATE characters SET temphealth='$currentHealthEnemy' WHERE user='$PoUS'")
or die(mysql_error());

        #mysql_query ("UPDATE characters SET exp = \"{$currentExp}\" WHERE user =".$_SESSION['user']."");  
    }
echo attack();
#Line 110
mysql_close();
?>
<form action="index.php" method="post">
<input type="submit" name="home" value="Back to home">



Thanks for your help

//Feelay

 

 

 


Reply

Jared
This is driving me mad too haha... But then again it's a bit tricky without actually having the database. The only thing I can think of right now is that there's an empty query somewhere. A query may be empty is syntax is off, rather than undefined.. This would cause the die() not to execute. So then perhaps mysql_result is thrown off and then it calls an error slightly after (PHP sometimes calls an error a few lines after the error has actually occured.. at least for me haha).

- Jared

Reply

mastercomputers
Hey Freelay,

This section here:

CODE
#Line 50
  if ( $winner ) {
    if ( ( $currentHealthEnemy - $healthAward ) > $minHealth ) {
      $currentHealthEnemy -= $healthAward;
      // $currentExp + expAward;
      echo 'You won! The enemy now have ' . $currentHealthEnemy . 'HP';


Confuses me with the operand -= which is the assignment by subtraction, but as far as I know, I've only used this in C++ and don't know if it was carried on over to PHP.

So you may have to do:

CODE
$currentHealthEnemy = $currentHealthEnemy - $healthAward;


Cheers,

MC

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Similar Topics

Keywords : unsupported, operand, types,

  1. File Types
    What File Type are allowed (7)
  2. C# Tutorial : Lesson 7 - Creating Value Types & Reference Types - Part II
    (1)
    foreach statement This statement is explicitly used to traverse through arrays. The
    benefit of using foreach over the normal for statement is that it is not needed to check the
    size of the array while using the former. Syntax:- foreach(type identifier in expression) {
    statement 1; statement 2; .... } Suppose we have an array StudentNames containing the name of all
    the students in a class. We need to display the name of each one of them on screen. First we will
    see how it can be done using the for loop. CODE string[] StudentNames = new s....
  3. C# Tutorial : Lesson 6 - Creating Value Types & Reference Types - Part I
    (0)
    Value Types & Reference Types In C#, Variables are either value types or reference types
    depending on what they store, values or references. By reference we imply that the variable holds
    the memory address of another location where the actual value is stored. All built in data types -
    Int, Char, String, Float, Boolean, etc are value types while classes are reference types. The
    following is a diagrammatic representation of these two types. In this picture there are two
    variables Num1 and Num2. Both of these being integer variables store the values directly.....
  4. Computer FTP Programs
    Both Free & Pay types (17)
    The only 2 DESCENT ones i know of is CuteFTP & SmartFTP, SmartFTP is the free one and so is CuteFTP
    for 30 days it's worth paying for the software but im not allowed to buy anything online atm so
    nothing being bought its out of the question really they both can be found by just entering them in
    yahoo or any search engine adding at the end Download obviously any way these are the two i only
    know about if you know any others that are better could you please reply and let me and others know
    what they are or just give me a PM when you can also could you agree or disagree....
  5. Battery Types Of Mobile Phones
    (1)
    Before continuing with my post, I must admit that this may not be the appropriate forum for posting
    this topic, however, I couldn't find one that's why posting it here. There are four types
    of batteries available for mobile phones: Nickel Cadmium (NiCd) These are least expensive of
    rechargable batteries, but suffer from inherent shortcomings like memory effect. Here, if the
    battery is not fully drained before recharging, the unused portion crystallizes hence the complete
    capacity of the battery is not fully used. Nickel Metal Hydride (NiMH) This technolo....
  6. Editing Menu Types In Mambo / Joomla
    How to change menu type and orientation (1)
    I want to ask about how to change menu type in Mambo / Joomla. Can we change menu type with tree,
    tab, or others ? Thank you....
  7. Help: $_post Variable For Options From Select Types?
    (6)
    I want to know if there is a way to get the variables in $_POST for the options (not just the
    selected ones, but the unselected ones as well) of a type. Objective: Creating an application for
    my school. Issue: I am successful in receiving all the variables from the forms except the ones
    added to the options of a type. Just wanted to know what is the variable to access the options of
    types. Here is what I am trying to do with it: View Page If the server is down or unable to
    load file, here is the script: CODE <html> <head>     ....
  8. Computer Powersupplies
    question on differnt types? (3)
    Hey, another question, related to my last thread. Are there different types of computer
    powersupplies? or are they all the same and can be used in all computers? I'm not refering to
    the different wattage of the supplies, simply if there are a variety of different types? I
    purchased a regular supply for my current computer as a replacement a while back and it had all the
    plugs I'm used to, but in my last thread here I mentioned I ran into an old computer. That
    computer's powersupply had most of the plugs I'm familiear with, but a few extra, plus some ....
  9. File Types
    (1)
    When I start to host is there any kind of restrictions on the type of files I host. Such as MP3s.....
  10. Frequency Types
    All Types of Frequency (0)
    EXTREMELY LOW-FREQUENCY Extremely low frequency or ELF refers to the band of radio frequencies
    from 3 to 30Hz. The purpose of the EXTREMELY LOW-FREQUENCY (elf) communications system is to send
    short "phonetic letter spelled out" (PLSO) messages from operating authorities to submarines
    operating at normal mission speeds and depths. Elf has the ability to penetrate ocean depths to
    several hundred feet with little signal loss. This ability allows submarines to be operated well
    below the immediate surface and enhances submarine survivability by making detection more diffi....
  11. Windows Reg data types
    (0)
    Below lists the data types currently defined and used by the Windows Reg. REG_SZ: A fixed-length
    text string. REG_FULL_RESOURCE_DESCRIPTOR: A series of nested arrays designed to store a resource
    list for a hardware component or driver. REG_EXPAND_SZ: A variable-length data string. This data
    type includes variables that are resolved when a program or service uses the data. REG_DWORD:
    Data represented by a number that is 4 bytes long. Many parameters for device drivers and services
    are this type and are displayed in Registry Editor in binary, hexadecimal, or d....

    1. Looking for unsupported, operand, types,

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for unsupported, operand, types,
advertisement




Unsupported Operand Types In / - What this =?



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE