Page 1 of 1

Need to flip a status bit in MySQL

Posted: Thu Sep 14, 2006 5:28 pm
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]

Posted: Thu Sep 14, 2006 5:53 pm
by ambivalent
It's the quotes, I believe:

Code: Select all

$result = mysql_query("UPDATE db_tbl SET status = '1'  WHERE id = '$id' ");

Posted: Fri Sep 15, 2006 10:06 am
by russia5
Thankyou Very Much! Your information made it work! Greg