Updating Databases using variables
Posted: Thu Nov 24, 2005 12:33 pm
I was writing some code to update one of my databases and figured it would be a lot easier to use variables then some long If/then statement, but i can't seem to figure out what's wrong with this code. Any help would be great.
Code: Select all
<?php
$bought = $_POST['bought'];
$conn = mysql_connect("localhost", "root", "") or die('Could not connect to the database: '.mysql_error());
mysql_select_db("countries", $conn) or die('Could not select the database: '.mysql_error());
$sql = "UPDATE improvements SET $bought = yes WHERE CONVERT(Country using utf8) = '$ID' LIMIT 1";
$res = mysql_query($sql) or die(mysql_error().'<p>SQL:<br />'.$sql.'</p>');
?>