Jump to content

'Unable to jump to row 0 on MySQL result index 6'


sam06

Recommended Posts

Any reason why?

It says on Line 32, which is

$referpoints = mysql_result ($check2, 0, 'totalpoints');

 

Entire Code:

 

<?
$clickid = $_POST['number']; 

mysql_connect("l****************") or die(mysql_error());
mysql_select_db("***********") or die(mysql_error());
// Change the offer to completed
mysql_query("UPDATE clicks SET complete='yes' WHERE clickid='$clickid'") 
or die(mysql_error());  
// Get the value of the offer completed
$check = mysql_query("SELECT value FROM clicks WHERE clickid='$clickid'") or die(mysql_error());
$offervalue = mysql_result ($check, 0, 'value');

//gets the username
$check123 = mysql_query("SELECT username FROM clicks WHERE clickid='$clickid'") or die(mysql_error());
$username = mysql_result ($check123, 0, 'username');

//gets the points the user has
$check1 = mysql_query("SELECT totalpoints FROM usertable WHERE username='$username'") or die(mysql_error());
$userpoints = mysql_result ($check1, 0, 'totalpoints');

$newtotal = $offervalue + $userpoints;
// updates the new total score
mysql_query("UPDATE usertable SET totalpoints='$newtotal' WHERE username='$username'") 
or die(mysql_error());  

//finds who reffered the person
$check6 = mysql_query("SELECT referrer FROM usertable WHERE username='$username'") or die(mysql_error());
$referrer = mysql_result ($check6, 0, 'referrer');

//gets the points the referrer has
$check2 = mysql_query("SELECT totalpoints FROM usertable WHERE username='$referrer'") or die(mysql_error());
$referpoints = mysql_result ($check2, 0, 'totalpoints');

$refvalue = $offervalue * 0.1;
$newpoints = $referpoints + $refvalue;

mysql_query("UPDATE usertable SET totalpoints='$newpoints' WHERE username='$referrer'") 
or die(mysql_error()); 


?>

Link to comment
Share on other sites

I read somewhere that nobody uses mysql_result anymore.

 

Granted, it is slower than the mysql_fetch_xxxx() functions for looping through results, but I still find it useful in queries with a single value result EG

 

$res = mysql_query ("SELECT COUNT(*) FROM mytable WHERE something");
if (mysql_result($res,0,0) > 0)
{
       // do something if there are records
}

 

as it saves having to fetch the row then test the column value.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.