sam06 Posted July 8, 2008 Share Posted July 8, 2008 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()); ?> Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted July 8, 2008 Share Posted July 8, 2008 I read somewhere that nobody uses mysql_result anymore. Not that they literally dont, but that there are better, easier, and more efficient practices. Can you explain what you're trying to do, then we can suggest a better way of doing it Quote Link to comment Share on other sites More sharing options...
Barand Posted July 8, 2008 Share Posted July 8, 2008 If you can't go to row 0 then no results were found by the query Quote Link to comment Share on other sites More sharing options...
Barand Posted July 8, 2008 Share Posted July 8, 2008 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. Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted July 8, 2008 Share Posted July 8, 2008 ^ point taken. Just not a practice I see very much at all. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.