For Some Strange Reason, This Wont Work?

Discussion in 'PHP' started by NateJ, May 18, 2009.

  1. #1
    For some strange reason, The echo wont Echo when $respecta = "2" however, when $respect == "1" it works :eek:

    Anyone know why? :confused:

    Here is the code i'm using:

    if (strip_tags($_POST['rbutton']) && strip_tags($_POST['ruser']) && strip_tags($_POST['ramount'])){
    $ramount=strip_tags($_POST['ramount']);
    $ruser=strip_tags($_POST['ruser']);
    $respecta=$_POST['respecta'];
    
    	if ($ramount == 0 || !$ramount || ereg('[^0-9]',$ramount)){
    	print "<font color=white>Invalid amount.";
    
    }elseif ($ramount != 0 || $ramount || !ereg('[^0-9]',$ramount)){
    
    if (strtolower($username) == strtolower($ruser)){
    echo "<font color=white>You cannot send points to yourself.";
    }elseif (strtolower($username) != strtolower($ruser)){
    
    $check=mysql_num_rows(mysql_query("SELECT * FROM users WHERE username='$ruser'"));
    if ($check == "0"){
    echo "<font color=white>No such user.";
    }elseif ($check != "0"){
    $respect_left = $user->respect - $ramount;
    mysql_query("UPDATE users SET respect=respect+$ramount WHERE username='$ruser'");
    mysql_query("UPDATE user_info SET respect='$respect_left' WHERE username='$username'");
    if ($respecta == "1"){
    mysql_query("INSERT INTO `inbox` ( `id` , `to` , `from` , `message` , `date` , `read` , `saved` , `event_id` , `witness` , `witness_per` )
    VALUES (
    '', '$ruser', '$ruser', 'Someone sent you $ramount respect points!', '$date', '0', '0', '0', '0', ''
    )");
    }elseif ($respecta == "2"){
    mysql_query("INSERT INTO `inbox` ( `id` , `to` , `from` , `message` , `date` , `read` , `saved` , `event_id` , `witness` , `witness_per` )
    VALUES (
    '', '$ruser', '$ruser', '$username sent you $ramount respect points!', '$date', '0', '0', '0', '0', ''
    )");
    echo "Respect Points Sent!";
    }}}}}
    PHP:
    Any Help will be greatly appreciated!

    Thanks,
    NateJ
     
    NateJ, May 18, 2009 IP
  2. exodus

    exodus Well-Known Member

    Messages:
    1,900
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    165
    #2
    
    <?php
                      if ($respecta == "1")
                      {
                          mysql_query("INSERT INTO `inbox` ( `id` , `to` , `from` , `message` , `date` , `read` , `saved` , `event_id` , `witness` , `witness_per` ) VALUES ( '', '$ruser', '$ruser', 'Someone sent you $ramount respect points!', '$date', '0', '0', '0', '0', '')");
                      }
                      if ($respecta == "2")
                      {
                          mysql_query("INSERT INTO `inbox` ( `id` , `to` , `from` , `message` , `date` , `read` , `saved` , `event_id` , `witness` , `witness_per` ) VALUES ( '', '$ruser', '$ruser', '$username sent you $ramount respect points!', '$date', '0', '0', '0', '0', '')");
                          echo "Respect Points Sent!";
                      }
    
    ?>
    PHP:
    Is it even going to that area of the code when $respecta == 2 ? I see nothing that would stop it from going that far unless something else is stopping it. Unless something changed from one form submit to the next form submit.
     
    exodus, May 18, 2009 IP
  3. NateJ

    NateJ Active Member

    Messages:
    240
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #3
    The query works, just the echo after it doesn't display.
     
    NateJ, May 18, 2009 IP
  4. octalsystems

    octalsystems Well-Known Member

    Messages:
    352
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    135
    Digital Goods:
    1
    #4
    try to use die in the place of echo check if the script halts there
     
    octalsystems, May 18, 2009 IP
  5. NateJ

    NateJ Active Member

    Messages:
    240
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #5
    I've Sorted the Problem, For some strange reason, it only worked when i put the echo before the queries :eek:
     
    NateJ, May 18, 2009 IP