Jump to content

Coding question?


Leveecius

Recommended Posts

Well here is the scripting I have for it right now, it doesn't really work.  It just displays the echo, but doesn't do anything else.

 

<?php
mysql_query("SELECT * FROM users WHERE username='$username'");
$purchase = ($cash-10000);
$heal = ($health+1);

if ($_POST['amount']){
$amount = ($_POST['amount']);
$healing = ($heal*$amount);
$cashloss = ($purchase*$amount);

mysql_query("UPDATE users WHERE health='$healing', cash='$cashloss'");}
?>

Link to comment
https://forums.phpfreaks.com/topic/180314-coding-question/#findComment-951965
Share on other sites

Hi

 

That update statement isn't updating anything, merely finding the row(s) to update (with a syntax error).

 

You would want something like:-

 

UPDATE users SET health='$healing', cash='$cashloss' WHERE username='$username'

 

However you do not appear to be doing anything with the records you have selected at the start of that code fragment.

 

All the best

 

Keith

Link to comment
https://forums.phpfreaks.com/topic/180314-coding-question/#findComment-952024
Share on other sites

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.