UPDATE a MySQL row -- Need Help --

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
ripcurlksm
Forum Commoner
Posts: 34
Joined: Sun Aug 08, 2004 9:17 pm

UPDATE a MySQL row -- Need Help --

Post by ripcurlksm »

I am posting an items 'id' from the url http://www.onestopauctionshop.net/spinc ... elling.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.

Code: Select all

<?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($queryResource, MYSQL_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>";


?>
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

What exactly are your errors ripcurlksm?.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

$sql = "UPDATE bookmark SET status='$title' WHERE id='$P_id'" . $row['id'] . "'";
That will result in a query that looks something like:
UPDATE bookmark SET status='whatever' WHERE id='4'.6'
which probably isn't what you want.
ripcurlksm
Forum Commoner
Posts: 34
Joined: Sun Aug 08, 2004 9:17 pm

Post by ripcurlksm »

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.

Here are the errors that show:
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/onestop/public_html/spinco/marksold.php on line 22

Notice: Query error SQL: SELECT id FROM bookmark WHERE status='selling' in /home/onestop/public_html/spinco/marksold.php on line 23

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

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/onestop/public_html/spinco/marksold.php on line 31

Notice: Query error SQL: UPDATE bookmark SET status='sold' WHERE id='2'' in /home/onestop/public_html/spinco/marksold.php on line 32


Regards,
Kevin
Post Reply