Results 1 to 3 of 3

Thread: lets play, find the error!

  1. #1
    Join Date
    Feb 2007
    Location
    Earth
    Posts
    127
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default lets play, find the error!

    PHP Code:
    <?php
    //no Mysql info for you :) 


    $username $_COOKIE['ID_my_site']; 
    $pass $_COOKIE['Key_my_site'];
    $check mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); 
    while(
    $info mysql_fetch_array$check ))
    {
    function 
    mySum($numX$numY){
    $total $numX $numY;
    return 
    $total
    }
    $newpoints $info['points'];
    echo 
    "Before now, your points were = "$newpoints ."<br />";
    // Store the result of mySum in $newpoints
    $newpoints mySum($info['points'], 1); 
    echo 
    "After now, your points are = " $newpoints ."<br />";

    mysql_query("UPDATE users SET points='$newpoints' WHERE points='$info[\'points\']' "
    or die(
    mysql_error());
    }
    ?>
    <a href="account.php">Continue?</a>
    Now i bet your wondering why i posted this here... well...

    Code:
    Parse error: parse error, unexpected T_BAD_CHARACTER, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\wamp\www\account\addpoints.php on line 21

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

    Default

    Code:
    <?php 
    // You might want to leave the actual lines in so that the line number makes sense.
    // Replace the details with Xs.
    
    $username = $_COOKIE['ID_my_site'];
    $pass = $_COOKIE['Key_my_site'];
    $check = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
    while($info = mysql_fetch_array( $check )) { 
      $newpoints = $info['points']; 
      echo "Before now, your points were = " . ($newpoints++) . "<br>"; 
      echo "After now, your points are = " . $newpoints ."<br>";
    
      mysql_query("UPDATE users SET points='$newpoints' WHERE points='{$info['points']}'") or die(mysql_error()); 
    }
    ?> 
    <a href="account.php">Continue?</a>
    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!

  3. #3
    Join Date
    Feb 2007
    Location
    Earth
    Posts
    127
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    PHP Code:
    //as always
    //thanks again twey :)
    //and ill remember to put the comments on :P
    //for next time 

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
  •