Epidemic Posted June 22, 2008 Share Posted June 22, 2008 Hello, I have recently done this script for my authentication script I am making. $scriptname=$item_name.'Min'; $myusername=$_COOKIE['userData']; $mins=10000; $sql="SELECT * FROM $tbl_name WHERE username='$myusername"; $result=mysql_query($sql); $rows=mysql_fetch_array($result); $mytime=$rows[$scriptname]; $newtime=$mins + $mytime; $sql="UPDATE $tbl_name SET $scriptname='$newtime' WHERE username='$myusername'"; $result=mysql_query($sql); header("location:thankyou.php"); If the item name is called cool, will my code add an extra 10,000 to the MySQL database in the collum coolMin of the username found from the cookie and then redirect to thankyou.php. I think it will work but it is for my PayPal IPN and I want to be sure and get some expert advice. Thanks. Link to comment https://forums.phpfreaks.com/topic/111350-solved-can-someone-check-my-code/ Share on other sites More sharing options...
abdfahim Posted June 22, 2008 Share Posted June 22, 2008 I dont know why you are writing so much. If i am not mistaken, you want to add 10000 to some column. Then it should go $scriptname=$item_name.'Min'; $myusername=$_COOKIE['userData']; $mins=10000; $sql="UPDATE $tbl_name SET `".$scriptname."`=(`".$scriptname."`+".$mins.") WHERE username='$myusername'"; $result=mysql_query($sql); header("location:thankyou.php"); Link to comment https://forums.phpfreaks.com/topic/111350-solved-can-someone-check-my-code/#findComment-571626 Share on other sites More sharing options...
Epidemic Posted June 22, 2008 Author Share Posted June 22, 2008 Would that reset the number to 10000 or would it add 10,000. However would my code work? Link to comment https://forums.phpfreaks.com/topic/111350-solved-can-someone-check-my-code/#findComment-571630 Share on other sites More sharing options...
DarkWater Posted June 22, 2008 Share Posted June 22, 2008 No, that'll add 10k to whatever in there. Link to comment https://forums.phpfreaks.com/topic/111350-solved-can-someone-check-my-code/#findComment-571632 Share on other sites More sharing options...
Epidemic Posted June 22, 2008 Author Share Posted June 22, 2008 Okay, Thank you very much Link to comment https://forums.phpfreaks.com/topic/111350-solved-can-someone-check-my-code/#findComment-571633 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.