SQL update problem

Post any questions you may have here

SQL update problem

Postby Christian on Fri May 09, 2008 7:31 pm

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:

Code: Select all
$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!
Christian
Fresh Boarder
 
Posts: 1
Joined: Fri May 09, 2008 7:22 pm

Re:SQL update problem

Postby GreyHead on Fri May 09, 2008 8:00 pm

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
Bob Janes
info at greyhead.net
ChronoForms Support If you like ChronoForms please vote or post a review at Joomla.org
User avatar
GreyHead
Platinum Boarder
 
Posts: 3082
Joined: Tue May 29, 2007 10:15 pm
Location: Brittany


Return to Questions & Answers

Who is online

Users browsing this forum: Yahoo [Bot] and 4 guests