Wrox Programmer Forums
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 18th, 2004, 06:43 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

When I say missing quotes, this...

$query1="UPDATE jackbecky SET sequence = ".$newsequence." WHERE id = ".$id;

...should be this:

$query1="UPDATE jackbecky SET sequence='".$newsequence."' WHERE id = '".$id."'";

But regardless of what I think, the hint I gave you should be enough to help you solve the problem.

HTH,

-Snib <><
http://www.snibworks.com
There are only two stupid questions: the one you don't ask, and the one you ask more than once :-)
 
Old September 18th, 2004, 09:29 PM
Authorized User
 
Join Date: Aug 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to dkittell Send a message via AIM to dkittell Send a message via Yahoo to dkittell
Default

Working Example:
Code:
<?PHP 
if ($sequence > $newsequence) 
{ 
   $link = mysql_connect("localhost","dbuser","dbpass"); 
   mysql_select_db("db",$link); 

   $query2="UPDATE jackbecky SET sequence='1000' WHERE id = ".$id.""; 
   mysql_query($query2) or die(mysql_error()); 

   $query1="UPDATE jackbecky SET sequence = ( sequence +1 ) WHERE sequence >=".$newsequence." AND sequence <=".$sequence.""; 
   mysql_query($query1) or die(mysql_error()); 

   $query1="UPDATE jackbecky SET sequence = ".$newsequence." WHERE id = ".$id.""; 
   mysql_query($query1) or die(mysql_error()); 

} 
if ($sequence < $newsequence) 
{ 
   $link = mysql_connect("localhost","dbuser","dbpass"); 
   mysql_select_db("db",$link); 

   $query2="UPDATE jackbecky SET sequence='1000' WHERE id = ".$id.""; 
   mysql_query($query2) or die(mysql_error()); 

   $query1="UPDATE jackbecky SET sequence = ( sequence -1 ) WHERE sequence <=".$newsequence." AND sequence >=".$sequence.""; 
   mysql_query($query1) or die(mysql_error()); 

   $query1="UPDATE jackbecky SET sequence = ".$newsequence." WHERE id = ".$id.""; 
   mysql_query($query1) or die(mysql_error()); 
} 

header("location:index.php") 
?>
---
David Kittell





Similar Threads
Thread Thread Starter Forum Replies Last Post
update multiple columns in an update statement debbiecoates SQL Server 2000 1 August 17th, 2008 04:01 AM
Update link doesn't update in FormsView shaly ASP.NET 2.0 Basics 0 December 6th, 2006 04:33 PM
Datagrid.update() and DataAdapter.Update aarunlal ASP.NET 2.0 Professional 2 February 23rd, 2006 11:41 PM
Sorting sunny76 Excel VBA 2 September 19th, 2005 09:31 PM
Datagrid sorting by non alphabetical sorting? LLAndy VS.NET 2002/2003 1 July 15th, 2004 01:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.