Replace value in database

I’m new here, so forgive me if this is the wrong place for this. ;D

Basically, there’s two columns, “name” and “value”. They’re like this;

name value
show_announcement 1
announcement This is an announcement.

I want to change the “This is an announcement.” to whatever the value of $announcement is.

[php]
$Query = “UPDATE table SET announcement=’{$announcement}’;”;
$Result = mysql_query($Query);
[/php]

Thanks. Why is this not working then?

[php]
$announcement=$_REQUEST[‘announcement’];
$showOrHideAnnouncement=$_REQUEST[‘showOrHideAnnouncement’];

$con = mysql_connect(“abc123”,“abc123”,“abc123”);
if (!$con){
die('Could not connect: ’ . mysql_error());
}
mysql_select_db(“abc123”, $con);

$Query = “UPDATE table SET announcement=’{$announcement}’;”;
$Result = mysql_query($Query);
$Query = “UPDATE table SET showOrHideAnnouncement=’{$showOrHideAnnouncement}’;”;
$Result = mysql_query($Query);
[/php]

[php]
$Query = “UPDATE table SET showOrHideAnnouncement=’{$showOrHideAnnouncement}’;”;
[/php]

  1. You originally said that the field name was show_announcement.
  2. If $ShowOrHideAnnouncement is an Integer, you don’t need the ’ symbols around it in the MySQL query:

[php]
$Query = “UPDATE table SET show_announcement={$showOrHideAnnouncement};”;
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service