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()); 


?>

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.