Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Database won't update
Old 11-22-2007, 03:22 AM Database won't update
MoForce's Avatar
Super Talker

Posts: 145
Name: Jack Shalt
Trades: 0
PHP Code:
$upbalance mysql_query("SELECT accountbalance FROM probid_users WHERE id='".$_POST['auctionid']."'");
                                    if (
$maxbid<=$upbalance) {
                                    
$nbalance $upbalance $maxbid;
                                    
$insertnewbalance mysql_query("UPDATE probid_users SET accountbalance='$nbalance' WHERE id='".$_SESSION['memberid']."'");
                                    } 
For some reason I don't know my database won't update the "accountbalance"

and yes $maxbid is defined and that's fine along with .$_POST['auctionid'].
PHP Code:
$insertnewbalance mysql_query("UPDATE probid_users SET accountbalance='$nbalance' WHERE id='".$_SESSION['memberid']."'"); 
This is really the line that's causing problems...

Thanks in advance for your help
MoForce is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-22-2007, 03:40 AM Re: Database won't update
VirusDoctor's Avatar
Skilled Talker

Posts: 53
Name: Shaun
Trades: 0
Hi Moforce, I'm not 100% sure about this but it would appear that you left out a required commas;

$insertnewbalance = mysql_query("UPDATE probid_users, SET accountbalance='$nbalance', WHERE id='".$_SESSION['memberid']."'");

Hope that helps.
VirusDoctor is offline
Reply With Quote
View Public Profile
 
Old 11-22-2007, 04:34 AM Re: Database won't update
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
Please read the manual and tell me what does mysql_query() return. Then tell me what is the value of $upbalance after calling mysql_query() in your case. After that you probably should resolve your problem.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 11-22-2007, 04:55 AM Re: Database won't update
maxxximus's Avatar
Extreme Talker

Posts: 219
Name: Rob
Location: UK
Trades: 0
Your $upbalance variable is merely a resource and cannot be used in a conditional statement. You need to use a mysql_fetch function to return an array and then use this array to extract the id value.

PHP Code:

$upbalance 
mysql_query("SELECT accountbalance FROM probid_users WHERE id='".$_POST['auctionid']."'");
$row mysql_fetch_assoc($upbalance);  
                              

if (
$maxbid<=$row['id']){  // rest of conditional 
</span></span>
maxxximus is offline
Reply With Quote
View Public Profile
 
Old 11-22-2007, 01:25 PM Re: Database won't update
MoForce's Avatar
Super Talker

Posts: 145
Name: Jack Shalt
Trades: 0
I fixed a part of the code..

PHP Code:
$upbalance getSqlField("SELECT accountbalance FROM probid_users WHERE id='".$_SESSION['memberid']."'","accountbalance");
        if (
$maxbid<=$upbalance) {
        
$nbalance $upbalance $maxbid
So now all of that is fine... but how can I update the database to replace the accountbalance to $nbalance?

PHP Code:
$insertnewbalance mysql_query("UPDATE probid_users SET accountbalance='$nbalance' WHERE id='".$_SESSION['memberid']."'"); 
That needs to be changed because the database isn't updating

Last edited by MoForce; 11-22-2007 at 01:34 PM..
MoForce is offline
Reply With Quote
View Public Profile
 
Old 11-22-2007, 06:54 PM Re: Database won't update
MoForce's Avatar
Super Talker

Posts: 145
Name: Jack Shalt
Trades: 0
Thanks for helping me out guys... I managed to figure it out..

PHP Code:
<? ## SUBTRACT BID FROM BALANCE!!!
        
$upbalance getSqlField("SELECT accountbalance FROM probid_users WHERE id='".$_SESSION['memberid']."'","accountbalance");
        if (
$maxbid<=$upbalance) {
        
$nbalance $upbalance $maxbid;
        
        
mysql_query("UPDATE probid_users SET accountbalance='$nbalance' WHERE id='".$_SESSION['memberid']."'");
        
                                    } 
?>
That's the working code in case any of you guys wondered
MoForce is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Database won't update
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.72481 seconds with 12 queries