I have a MySQL table which as fields ‘id’ and ‘confirm_code’. Type for confirm_code is varchar(65).
<?php
$check= 3;
mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
mysql_select_db("database")or die("cannot select DB");
$result = mysql_query("UPDATE testmembers SET confirm_code = $check WHERE id=1")
or die(mysql_error());
?>
Works fine.
<?php
$check = md5(uniqid(rand()));
mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
mysql_select_db("database")or die("cannot select DB");
$result = mysql_query("UPDATE testmembers SET confirm_code = $check WHERE id=1")
or die(mysql_error());
?>
Generates a MYSQL error such as “Unknown column '63192106849063b525aa5d6ac296d822' in 'field list' “.
I can’t se that varchar is the wrong type to handle the random variable – in another table it copes with
$confirm_code=md5(uniqid(rand()));
$sql="INSERT INTO $tbl_name(confirm_code, email)VALUES('$confirm_code', '$email')";
Any ideas where my problem lies?