Forums

SQL update problem

Christian 09 May, 2008
Hi,

i'm sorry, my english is not really good, but i try to explain my problem:

I need to update some tables by a form.
Instead of the auto-generated code I use this one:


$database =& JFactory::getDBO();
$user = & JFactory::getUser();
$user_id = $user->get('id');
srand((double)microtime()*10000);
$inum	=	"I" . substr(base64_encode(md5(rand())), 0, 16);
	
$database->setQuery( "UPDATE #__chronoforms_1 SET  (
'' , '".$inum."','". date('Y-m-d')." - ".date("H:i:s")."',
'".$_SERVER['REMOTE_ADDR']."',
Kartenmenge='".JRequest::getVar('Kartenmenge','', 'post',
'string', '' )."')
WHERE {id==$user_id} " );
if (!$database->query()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>
";
}


I don't get an error message, but the updated data is not written to the database.
Has anyone an idea what's wrong with my code?

Thank you!
GreyHead 09 May, 2008
Hi Christian,

In a rush but this looks wrong:

WHERE {id==$user_id}

that's PHP syntax in a MySQL query try

where id='$user_id'

Bob
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger