Need to flip a status bit in MySQL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
russia5
Forum Newbie
Posts: 12
Joined: Sun May 22, 2005 8:07 pm
Location: California
Contact:

Need to flip a status bit in MySQL

Post by russia5 »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I have coded an email list with a confirmation letter.  The php I have developed puts the posted email into a MySQL table, generates an md5 hash and puts that in and puts in a status bit.  It works fine.  The confirmation letter is sent with the confirmation URL.  Simular to this:


http://www.mysite.com/confirm.php?id=10 ... 3f716dafa1

$id = md5 hash
$status = "1" or "0"

The query sting is suppose to change the status bit associated with the record from "0" to "1".  I believe that would be an UPDATE

Here is the confirm.php

Code: Select all

<?php

$id = ($_GET['id']);

include_once ("config.php");

$result = mysql_query('UPDATE db_tbl
SET status = '1'
WHERE id = $id');
if (!$result) {
   die('Invalid query: ' . mysql_error());
}

?>
Here is the error.

Parse error: parse error, unexpected T_LNUMBER in /home/russia5/public_html/confirm.php on line 11

Line 11 is set status = 1

Anyone see the problem?

Thankyou to all that consider the question!

Greg


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
ambivalent
Forum Contributor
Posts: 173
Joined: Thu Apr 14, 2005 8:58 pm
Location: Toronto, ON

Post by ambivalent »

It's the quotes, I believe:

Code: Select all

$result = mysql_query("UPDATE db_tbl SET status = '1'  WHERE id = '$id' ");
russia5
Forum Newbie
Posts: 12
Joined: Sun May 22, 2005 8:07 pm
Location: California
Contact:

Post by russia5 »

Thankyou Very Much! Your information made it work! Greg
Post Reply