Click here to Skip to main content
15,921,210 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey
please i want to do something that update a MySQL field by adding interger to it but it doesn't work :S, here is my code
PHP
$credits2 = intval($credits);
mysql_query("UPDATE secretcodes SET uses=uses + $credits2 WHERE secretcode='$secretcode'");

Please help
Thanks in advance
Posted

You could try something like:
mysql_query("UPDATE secretcodes SET uses=uses + ".$credits2." WHERE secretcode='".$secretcode."'")

However, that would be a potential security risk because of SQL injections etc. So perhaps a better approach would be to investigate MySQL improved extension[^]
 
Share this answer
 
Comments
Seif Hatem 9-May-12 15:58pm    
This will be used in Admin control panel so no worries :)
Seif Hatem 9-May-12 16:00pm    
It's not working!
Seif Hatem 9-May-12 16:03pm    
IT was my fault the column in database is called code not secret code, sorry :$ :)
Wendelius 9-May-12 16:18pm    
No problem, the main thing is that it got solved :)
you can use this solution also

PHP
mysql_query("UPDATE secretcodes SET uses= concat(uses , '".$credits2."') WHERE secretcode='".$secretcode."'")
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900