Results 1 to 7 of 7

Thread: Beast attack

  1. #1
    Join Date
    Feb 2007
    Location
    Earth
    Posts
    133
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default Beast attack

    fixed!
    Last edited by Demonicman; 10-25-2007 at 04:51 AM.
    http://www.insanecombat.com << bored? check out ma game

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    The problem may lie here: $User[ID]
    That syntax doesn't look right, as in double quotes only simple variables are parsed, and ID would be a constant there, which has not been defined; however, 'ID' would be a valid index in the array. (ID, by itself, is a constant, like $ID, but having been set with define().)

    In the end, the error itself is because the query returned no results.

    Embedding mysql_fetch_array(mysql_query($query)) all in one makes troubleshooting and error compensation tough; separate them to make things easier.
    $query = 'stuff here'; //then you can echo it to check
    $result = mysql_query($query); //now you can use $result
    //you could use mysql_num_rows to see if there was any match
    THEN, $row = mysql_fetch_array($result);
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Feb 2007
    Location
    Earth
    Posts
    133
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default

    wow, i appreciate your help, thx
    Last edited by Demonicman; 10-25-2007 at 04:50 AM.
    http://www.insanecombat.com << bored? check out ma game

  4. #4
    Join Date
    Feb 2007
    Location
    Earth
    Posts
    133
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default

    Nvm Fixed
    Last edited by Demonicman; 10-25-2007 at 04:50 AM.
    http://www.insanecombat.com << bored? check out ma game

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    I'm not sure what's confusing.

    ID by itself would be a constant, which is similar to a variable in PHP but simply stores a constant value. Just like "3" represents the numerical value of 3, ID could represent a set numerical value of "5", if set as such. (Though it can store any type of data, not just numbers.)

    The difference between a constant and a variable is that a variable is easily accessible and changed; a constant is set once with the define() function.

    So... the point... you AREN'T using this, especially if you don't understand it.

    You want to use an index, which is a name for a part of an array.

    $array[a] would be using the constant a, and that's just not what you want.
    $array['a'] would give the 'a' element of the array.


    As for splitting it up, that should be self explanatory. As per the comments above, error check to see where the problem lies. Is it the query? Does it return rows (checked with mysql_num_rows)?
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    It would be preferable to leave the question there for future readers.
    $array[a] would be using the constant a, and that's just not what you want.
    It should be noted that undefined constants are automatically interpreted as strings (here, for example, $array[a] is interpreted as $array['a']). However, relying on this is a bad idea, since if someone does define a constant 'a' it will muck everything up (and it's deprecated, and will throw a warning).
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Removing the question is quite annoying. It's important to leave this as a resource for others who have the same question so they can search and so we can link to this as a solution.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •