Hi all i need some help with my code. i have a page where i want to update a row 'key' in my table users with a new value that i have generated.
dbc.php

<?php
$dbname = 'phplogin';
$link = mysql_connect("localhost","root","") or die("Couldn't make connection.");
$db = mysql_select_db($dbname, $link) or die("Couldn't select database");
?>

keyinput.php

<?php session_start(); 

include ('dbc.php'); 

		$keys = rand(1000,9999);
		$id = $_SESSION['user_name'];
		echo $id;
		echo $keys;
		mysql_query("UPDATE users SET key = '$keys' WHERE id = '$id'");

?>

i am able to echo the values id and keys, and it gives me legitimate results. however, the sql query does not update the row like i want it to.
Any ideas?
thanks
Danny

I didn't find any mistake in your code. Embed fields with apostrophe - may be a name of field violates mysql.

mysql_query("UPDATE `users`  SET `key` = '$keys' WHERE `id` = '$id'");

I didn't find any mistake in your code. Embed fields with apostrophe - may be a name of field violates mysql.

mysql_query("UPDATE `users`  SET `key` = '$keys' WHERE `id` = '$id'");

hey thanks alot apparently it has solved the problem.
Thanks again

This question has already been answered. Start a new discussion instead.