Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old December 16th, 2002, 11:08 PM
boehmr boehmr is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 3 boehmr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
simple multiple ROW UPDATE?

i have a table that i only want to update two fields. (rate, apy).
for an example i only have two entries. i've posted the code i'm
trying to use, but with no luck. can someone please help me?
thank you in advance!
----------

<html>
<body>
<?
require "../include/settings.inc";

if ($submit) {

// process form

$db = mysql_connect($host, $user, $password);
mysql_select_db($database,$db);
$sql = "UPDATE account_rates SET rate='$platinum', apy='$platinum_apy' WHERE id= 1";
$sql .= "AND SET rate='$checkingplus', apy='$checkingplus_apy' WHERE id= 2";
mysql_query($sql);
echo "Thank you! Information has been updated.n";

} else{

// display form

?>

<form method="post" action="<? echo $PHP_SELF?>">
Platinum Rate:<input type="Text" name="platinum"><br>
Platinum APY:<input type="Text" name="platinum_apy"><br>
Checking Plus Rate:<input type="Text" name="checkingplus"><br>
Checking Plus APY:<input type="Text" name="checkingplus_apy"><br>
<input type="Submit" name="submit" value="Enter information">
</form>

<?php

} // end if

?>
</body>
</html>
----------------

Reply With Quote
  #2  
Old December 16th, 2002, 11:22 PM
bob0099 bob0099 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: manchester,n.h.,usa
Posts: 172 bob0099 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
RE: simple multiple ROW UPDATE?

WHERE id= 1

WHERE id= 2

should be:

WHERE id= '1'

WHERE id= '2'
at least thats the way I would write it. If anyone else can elaborate it would be great.

Reply With Quote
  #3  
Old December 16th, 2002, 11:48 PM
boehmr boehmr is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 3 boehmr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: simple multiple ROW UPDATE?

thanks, but either way i write it,
with '1' or without 1, it still doesn't work.

Reply With Quote
  #4  
Old December 17th, 2002, 12:21 AM
bob0099 bob0099 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: manchester,n.h.,usa
Posts: 172 bob0099 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
RE: simple multiple ROW UPDATE?

try splitting up the query into two separate ones and see which is causing the problem.

also do you have register globals set to yes in php.ini? If not you will have to pull your post data from $_POST[] variables.
Example $sql = "UPDATE account_rates SET rate='$_POST[platinum]'.......

Reply With Quote
  #5  
Old December 17th, 2002, 12:43 PM
hermawan's Avatar
hermawan hermawan is offline
Superman is not dead
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: Jakarta, Indonesia
Posts: 553 hermawan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 44 m 37 sec
Reputation Power: 3
Send a message via ICQ to hermawan Send a message via AIM to hermawan Send a message via Yahoo to hermawan Send a message via Google Talk to hermawan Send a message via Skype to hermawan
RE: simple multiple ROW UPDATE?

Try to capture the variable $sql before you do mysql_query(), run it on phpMyAdmin. I'm sure that phpMyAdmin will said that the sql statement is bad. If you want to update 2 row with different ID or nothing is same between those 2 row then you have to do the sql execution twice.

Reply With Quote
  #6  
Old December 17th, 2002, 03:37 PM
boehmr boehmr is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 3 boehmr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: simple multiple ROW UPDATE?

that did it!
sometimes it helps for someone
with fresh eyes to see an easy solution.
thanks again all!

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > simple multiple ROW UPDATE?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 10 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek