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

Thanks,
Mark this thread as a "Solved".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.