Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

MySQL Update not working...

Asked Modified Viewed 2,388 times
U
Unknown98
U
  • Member, joined since
  • Contributed 113 posts on the community forums.
  • Started 32 threads in the forums
  • Started this discussions
asked
Member

Well I'm back again lol.


<?php

if (!is_numeric($_POST['deposit']) || $_POST['deposit'] <100)
{
echo "Please enter at least $100 for the deposit.";
echo "<br><br>";
}

If ($userdata['strength'] <2 || $userdata['money'] <0 ){

echo "You don't qualify! You need at least 2 strength and have positive money.";
echo "<br><br>";
}else{

$up="UPDATE fusion_users set money=money-".$_POST['deposit']." where user_id = '".$userdata['user_id']."'";
mysql_query($up) or die("error");

$up="Update fusion_users set strength=strength-2 where user_id = '".$userdata['user_id']."'";
mysql_query($up) or die("error");

$up="UPDATE bank set account_money=account_money+".$_POST['deposit']." where founder_username = '".$userdata['user_id']."'";
mysql_query($up) or die("error");

echo "Congrats! You've just deposited!";

}

?>


The form is processing and displaying errors & sucess messages fine, but the data is not being updated in the DB. the Table entitled "bank":

www.vulomedia.com/thumbs/72196php.jpg
Edited by Unknown98 on 04-09-2008 04:03,
0 replies

8 posts

G
googlebot
G
Visit the new home of the merge between Hacking Vs. Security and Security Override!
My copyright removal has been switched over from HvS to SecurityOverride.
  • Senior Member, joined since
  • Contributed 638 posts on the community forums.
  • Started 28 threads in the forums
answered
Senior Member

It's simpler to use a statement like this:

$var = mysql_query("UPDATE PREFIX_table SET money = 1000 WHERE user_id = '".$userdata['user_id']."'");

Of course you'll have to change it accordingly. Try changing it, replacing the code, and report back. (I used that exact line (except altered of course) about 15 minutes ago, so I know it works).
0 replies
U
Unknown98
U
  • Member, joined since
  • Contributed 113 posts on the community forums.
  • Started 32 threads in the forums
  • Started this discussions
answered
Member

I'll try it, thanks.
0 replies
U
Unknown98
U
  • Member, joined since
  • Contributed 113 posts on the community forums.
  • Started 32 threads in the forums
  • Started this discussions
answered
Member

Still isn't updating.

$var = mysql_query("UPDATE PREFIX_bank SET account_money = account_money+".$_POST['deposit']." WHERE user_id = '".$userdata['user_id']."'");
0 replies
G
googlebot
G
Visit the new home of the merge between Hacking Vs. Security and Security Override!
My copyright removal has been switched over from HvS to SecurityOverride.
  • Senior Member, joined since
  • Contributed 638 posts on the community forums.
  • Started 28 threads in the forums
answered
Senior Member

Quote

Unknown98 wrote:
Still isn't updating.

$var = mysql_query("UPDATE PREFIX_bank SET account_money = account_money+".$_POST['deposit']." WHERE user_id = '".$userdata['user_id']."'");

You didn't change "PREFIX_" which is right after "UPDATE". You have to edit it to your prefix (for example, my table would be fusion_tablename because my prefix is fusion_ )
Edited by googlebot on 04-09-2008 23:26,
0 replies
U
Unknown98
U
  • Member, joined since
  • Contributed 113 posts on the community forums.
  • Started 32 threads in the forums
  • Started this discussions
answered
Member

Still doesn't work


$var = mysql_query("UPDATE fusion_bank SET account_money = account_money+".$_POST['deposit']." WHERE user_id = '".$userdata['user_id']."'");
0 replies
G
googlebot
G
Visit the new home of the merge between Hacking Vs. Security and Security Override!
My copyright removal has been switched over from HvS to SecurityOverride.
  • Senior Member, joined since
  • Contributed 638 posts on the community forums.
  • Started 28 threads in the forums
answered
Senior Member

Quote

Unknown98 wrote:
Still doesn't work


$var = mysql_query("UPDATE fusion_bank SET account_money = account_money+".$_POST['deposit']." WHERE user_id = '".$userdata['user_id']."'");

Post your whole code (new code, with my sql syntax).
0 replies
U
Unknown98
U
  • Member, joined since
  • Contributed 113 posts on the community forums.
  • Started 32 threads in the forums
  • Started this discussions
answered
Member


<?php

if (!is_numeric($_POST['deposit']) || $_POST['deposit'] <100)
{
echo "Please enter at least $100 for the deposit.";
echo "<br><br>";
}

If ($userdata['strength'] <2 || $userdata['money'] <0 ){

echo "You don't qualify! You need at least 2 strength and have positive money.";
echo "<br><br>";
}else{

$var = mysql_query("UPDATE fusion_bank SET account_money = account_money+".$_POST['deposit']." WHERE user_id = '".$userdata['user_id']."'");

$var = mysql_query("UPDATE fusion_users SET money = money-".$_POST['deposit']." WHERE user_id = '".$userdata['user_id']."'");

$var = mysql_query("UPDATE fusion_users SET strength = strength-2 WHERE user_id = '".$userdata['user_id']."'");

echo "Congrats! You've just deposited!";

}

?>
0 replies
G
googlebot
G
Visit the new home of the merge between Hacking Vs. Security and Security Override!
My copyright removal has been switched over from HvS to SecurityOverride.
  • Senior Member, joined since
  • Contributed 638 posts on the community forums.
  • Started 28 threads in the forums
answered
Senior Member

I'll play with the code tomorrow if I have time.
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 8 posts
  • Votes 0 votes
  • Topic users 2 members

0 participants

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet