PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old August 21st, 2004, 07:42 AM
ripcurlksm ripcurlksm is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 4 ripcurlksm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 8 sec
Reputation Power: 0
UPDATE a MySQL row -- Need Help --

I am posting an items 'id' from the url http://www.onestopauctionshop.net/spinco/admin_allusersselling.php so that I can change the status of an item from 'status = selling' to 'status ='sold'

I am getting a bunch of errors, which you will see if you click on the "Mark Sold!" link from the above url.

Basicaly, I want it to $_GET the id from the url, then take that id number and change the status column for that item from 'selling' to 'sold.' Is there a better way to maintain the status of an item (i.e.- selling, sold and shipped). I just need a way to keep track of an item while its being processed.

PHP Code:
<?php
  $P_id 
$_GET['id'];
  
  
mysql_connect(localhost,$username,$password);
  @
mysql_select_db($database) or die( "Unable to select database");
  
   
// A query to select the item 'id'
  
$sql "SELECT id FROM bookmark WHERE status='selling'";
  if (!
$queryResource mysql_query($sql$dbConn)) {
  
trigger_error('Query error ' mysql_error() . ' SQL: ' $sql);
  }
  
// Fetch a single row from the result
  
$row mysql_fetch_array($queryResourceMYSQL_ASSOC);
  
// A new title
  
$title 'sold';
  
  
$sql "UPDATE bookmark SET status='$title' WHERE id='$P_id'" $row['id'] . "'";
  if (!
$queryResource mysql_query($sql$dbConn)) {
  
trigger_error('Query error ' mysql_error() . ' SQL: ' $sql);
  }
  
  
  
  echo 
"Sold! <a href='http://onestopauctionshop.com/spinco/AdMiN.htm'>Back</a>";
  
  
  
?>

Reply With Quote
  #2  
Old August 21st, 2004, 07:56 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 956 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 6 Days 8 h 23 m 34 sec
Reputation Power: 4
Send a message via ICQ to Itsacon
Seems to me you're working with two id's, the one from the GET array, and the one you get from the database.
I don't know which of the two is the one you want, but this way, your update query is incorrect, it will look something like this:
UPDATE bookmark SET status='sold' WHERE id='1' 2 '

I think the '$row['id'] shouldn't be there, replacing that line with:
PHP Code:
 $sql "UPDATE bookmark SET status='$title' WHERE id='$P_id'"


Hope this is what you meant

Reply With Quote
  #3  
Old August 21st, 2004, 11:23 AM
ripcurlksm ripcurlksm is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 4 ripcurlksm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 8 sec
Reputation Power: 0
...

Well, there is really only one id, which is pulled from the browser ($_GET). I need the script to say "Find this id number in the table and change the 'status' of it from 'selling' to 'sold'.

I made your changes and I am getting these errors, I have also added the lines of code with each error message....
Quote:
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/onestop/public_html/spinco/marksold.php on line 22
PHP Code:
if (!$queryResource mysql_query($sql$dbConn)) { 


Notice: Query error SQL: SELECT id FROM bookmark WHERE status='selling' in /home/onestop/public_html/spinco/marksold.php on line 23
PHP Code:
 trigger_error('Query error ' mysql_error() . ' SQL: ' $sql); 


Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/onestop/public_html/spinco/marksold.php on line 26
PHP Code:
 $row mysql_fetch_array($queryResourceMYSQL_ASSOC); 


Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/onestop/public_html/spinco/marksold.php on line 31
PHP Code:
if (!$queryResource mysql_query($sql$dbConn)) { 


Notice: Query error SQL: UPDATE bookmark SET status='sold' WHERE id='2' in /home/onestop/public_html/spinco/marksold.php on line 32
PHP Code:
 trigger_error('Query error ' mysql_error() . ' SQL: ' $sql); 

Reply With Quote
  #4  
Old August 22nd, 2004, 10:29 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 956 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 6 Days 8 h 23 m 34 sec
Reputation Power: 4
Send a message via ICQ to Itsacon
I think this part of the code should be enough:

PHP Code:
<?php
  $P_id 
$_GET['id'];
  
  
mysql_connect(localhost,$username,$password);
  @
mysql_select_db($database) or die( "Unable to select database");
  
  
// A new title
  
$title 'sold';
  
  
$sql "UPDATE bookmark SET status='$title' WHERE id='$P_id'";
  if (!
$queryResource mysql_query($sql$dbConn)) {
  
trigger_error('Query error ' mysql_error() . ' SQL: ' $sql);
  }
    
  
  echo 
"Sold! <a href='http://onestopauctionshop.com/spinco/AdMiN.htm'>Back</a>";
  
  
  
?>

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > UPDATE a MySQL row -- Need Help --


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


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





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway