Announcement

Collapse
No announcement yet.

PHP and MySQL Problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PHP and MySQL Problem

    I am getting the following error:
    Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 9 in /home/www/home.stickpay.com/members/upgrade.php on line 47

    Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 9 in /home/www/home.stickpay.com/members/upgrade.php on line 48

    Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 9 in /home/www/home.stickpay.com/members/upgrade.php on line 49

    Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 10 in /home/www/home.stickpay.com/members/upgrade.php on line 59

    This is the lines from the scripr:

    Code:
    $spon = mysql_result($result,0,"userid");
    $sponrang = mysql_result($result,0,"memtype");
    $sponofspon = mysql_result($result,0,"referid");
    
    if($sponrang > $memtype){
    $paysponsor = "$spon";
    }
    else{
    $result = mysql_query( " SELECT * FROM members WHERE `userid` = '$sponofspon' " );
    $num = mysql_num_rows($result);
    
    
    $spon1 = mysql_result($result,0,"userid");
    Does anyone know how to fix this?

    Thanks!

  • #2
    I would need to see the rest of that if .. else statement.

    Comment


    • #3
      Originally posted by clivejo View Post
      I would need to see the rest of that if .. else statement.
      PHP Code:
      <?


      $result 
      mysql_query" SELECT * FROM members WHERE `userid` = '$referid' " );

      $num mysql_num_rows($result);


      $spon mysql_result($result,0,"userid");
      $sponrang mysql_result($result,0,"memtype");
      $sponofspon mysql_result($result,0,"referid");

      if(
      $sponrang $memtype){
      $paysponsor "$spon";
      }
      else{
      $result mysql_query" SELECT * FROM members WHERE `userid` = '$sponofspon' " );
      $num mysql_num_rows($result);


      $spon1 mysql_result($result,0,"userid");
      $sponrang1 mysql_result($result,0,"memtype");
      $sponofspon1 mysql_result($result,0,"referid");

      if(
      $sponrang1 $memtype){
      $paysponsor "$spon1";
      }
          else{
      $result mysql_query" SELECT * FROM members WHERE `userid` = '$sponofspon1' " );
      $num mysql_num_rows($result);


      $spon2 mysql_result($result,0,"userid");
      $sponrang2 mysql_result($result,0,"memtype");
      $sponofspon2 mysql_result($result,0,"referid");

      if(
      $sponrang2 $memtype){
      $paysponsor "$spon2";
      }

      else{
      $result mysql_query" SELECT * FROM members WHERE `userid` = '$sponofspon2' " );
      $num mysql_num_rows($result);


      $spon3 mysql_result($result,0,"userid");
      $sponrang3 mysql_result($result,0,"memtype");
      $sponofspon3 mysql_result($result,0,"referid");

      if(
      $sponrang3 $memtype){
      $paysponsor "$spon3";
      }

      else{
      $result mysql_query" SELECT * FROM members WHERE `userid` = '$sponofspon3' " );
      $num mysql_num_rows($result);


      $spon4 mysql_result($result,0,"userid");
      $sponrang4 mysql_result($result,0,"memtype");
      $sponofspon4 mysql_result($result,0,"referid");

      if(
      $sponrang4 $memtype){
      $paysponsor "$spon4";
      }
      else{
      $result mysql_query" SELECT * FROM members WHERE `userid` = '$sponofspon4' " );
      $num mysql_num_rows($result);


      $spon5 mysql_result($result,0,"userid");
      $sponrang5 mysql_result($result,0,"memtype");
      $sponofspon5 mysql_result($result,0,"referid");

      if(
      $sponrang5 $memtype){
      $paysponsor "$spon5";

      }

          else{
      $result mysql_query" SELECT * FROM user WHERE `userid` = '$sponofspon5' " );
      $num mysql_num_rows($result);


      $spon6 mysql_result($result,0,"userid");
      $sponrang6 mysql_result($result,0,"memtype");
      $sponofspon6 mysql_result($result,0,"referid");

      if(
      $sponrang6 $memtype){
      $paysponsor "$spon6";

      }
          else{
      $result mysql_query" SELECT * FROM members WHERE `userid` = '$sponofspon6' " );
      $num mysql_num_rows($result);


      $spon7 mysql_result($result,0,"userid");
      $sponrang7 mysql_result($result,0,"memtype");
      $sponofspon7 mysql_result($result,0,"referid");

      if(
      $sponrang7 $memtype){
      $paysponsor "$spon7";
      }

      else
          {
      $result mysql_query" SELECT * FROM members WHERE `userid` = 'admin' " );
      $num mysql_num_rows($result);


      $spon8 mysql_result($result,0,"userid");
      $sponrang8 mysql_result($result,0,"memtype");
      $sponofspon8 mysql_result($result,0,"referid");

      if(
      $sponrang8 $memtype){
      $paysponsor "$spon8";
      }
      }
      }
      }
      }
      }
      }
      }
      }

      ?>

      Comment


      • #4
        Looks like the first query is failing.

        I would try a couple of echoes to try to debug.

        Code:
        <?
        
        [B][COLOR="Red"]echo $referid;[/COLOR][/B]
        
        $result = mysql_query( " SELECT * FROM members WHERE `userid` = '$referid' " );
        
        $num = mysql_num_rows($result);
        
        [B][COLOR="Red"]echo $num;[/COLOR][/B]
        
        
        $spon = mysql_result($result,0,"userid");
        $sponrang = mysql_result($result,0,"memtype");
        $sponofspon = mysql_result($result,0,"referid");
        
        if($sponrang > $memtype){
        $paysponsor = "$spon";
        }
        It might be either there is no physical row in your table members, with userid=$referid, or maybe the value of $referid is not getting picked up correctly and passed into this script.

        Comment


        • #5
          Thank you for the help that you are giving.

          echo $num; shows a value of "0".

          echo $referid; gives no value at all.

          Comment


          • #6
            This script needs a valid value for $referid to function, looks like it is currently NULL. If you provide the script with a valid userid in the database, it will work.

            For example, to work with userid = 1.

            Code:
            <?
            [B]
            [COLOR="Red"]$referid=1;[/COLOR][/B]
            
            $result = mysql_query( " SELECT * FROM members WHERE `userid` = '$referid' " );
            
            $num = mysql_num_rows($result);
            
            echo $num;
            
            
            $spon = mysql_result($result,0,"userid");
            $sponrang = mysql_result($result,0,"memtype");
            $sponofspon = mysql_result($result,0,"referid");
            
            if($sponrang > $memtype){
            $paysponsor = "$spon";
            }
            Last edited by clivejo; 17-05-2013, 10:59 PM.

            Comment


            • #7
              I'm a little confused, because I thought that:
              ( " SELECT * FROM members WHERE `userid` = '$referid' " );

              used the "userid" value from the database and gave it's value to "$referid".

              If that is true then "$referid" would have a value.

              Please help me understand the flaw in my thinking.

              Comment


              • #8
                Originally posted by iads View Post
                I'm a little confused, because I thought that:
                ( " SELECT * FROM members WHERE `userid` = '$referid' " );

                used the "userid" value from the database and gave it's value to "$referid".

                If that is true then "$referid" would have a value.

                Please help me understand the flaw in my thinking.
                No, the SELECT command is asking the database a question. This SQL statement is asking the database to return a member where the userid is the same as the value in $referid. The * means return the entire row ie all the fields. This information is then fed into the $results variable.

                So to a human this read "Please look in the members table for a member(or members) with a userid matching the information stored in pigeon hole called $referid. I want to know everything you hold about this member and can you put it in the pigeon hole called $results" Unfortunately there is nothing stored in $referid for it to work, so it returns nothing as $results. The next lines then are trying to extract data from $results but cant as there is nothing to work with!

                Try this :

                Code:
                <?
                
                $result = mysql_query( " SELECT * FROM members WHERE `userid` = '$referid' " );
                
                [COLOR="Red"][B]if (is_null($results) {echo "No members found with user id = $referid$"}[/B][/COLOR]
                
                $num = mysql_num_rows($result);
                
                $spon = mysql_result($result,0,"userid");
                $sponrang = mysql_result($result,0,"memtype");
                $sponofspon = mysql_result($result,0,"referid");
                Last edited by clivejo; 17-05-2013, 11:14 PM.

                Comment


                • #9
                  I forgot to say thank you for your help!!!

                  Comment


                  • #10
                    Did you get it working?

                    Comment


                    • #11
                      Originally posted by clivejo View Post
                      Did you get it working?
                      I used your tweeks to make it a better code, but the ultimate fix was creating 10 fake accounts that work as place holders. Any accounts that are created after those 10 work great. Again thanks...

                      Comment

                      Working...
                      X