I'm using Joomla! 1.5
How do I use the form to UPDATE a table instead of INSERTing new rows? I changed the AutoGenerated code to:
<?php
$database =& JFactory::getDBO();
$database->setQuery( "UPDATE #__chronoforms_8 VALUES (
'' , '". date('Y-m-d')." - ".date("H:i:s")."', '".$_SERVER['REMOTE_ADDR']."' , '".JRequest::getVar('fullname','', 'post', 'string', '' )."' , '".JRequest::getVar('firstname','', 'post', 'string', '' )."' , '".JRequest::getVar('middlename','', 'post', 'string', '' )."' , '".JRequest::getVar('lastname','', 'post', 'string', '' )."' , '".JRequest::getVar('addressa','', 'post', 'string', '' )."' , '".JRequest::getVar('addressb','', 'post', 'string', '' )."' , '".JRequest::getVar('city','', 'post', 'string', '' )."' , '".JRequest::getVar('state','', 'post', 'string', '' )."' , '".JRequest::getVar('zipcode','', 'post', 'string', '' )."' WHERE 'uid'='$uid'");" );
if (!$database->query()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>
";
}
?>
I got:
Parse error: syntax error, unexpected '>' in /home/laborat2/public_html/lcs1/components/com_chronocontact/chronocontact.php(525) : eval()'d code on line 7<br><br>Post edited by: slashchuck, at: 2008/03/18 05:12
How do I use the form to UPDATE a table instead of INSERTing new rows? I changed the AutoGenerated code to:
<?php
$database =& JFactory::getDBO();
$database->setQuery( "UPDATE #__chronoforms_8 VALUES (
'' , '". date('Y-m-d')." - ".date("H:i:s")."', '".$_SERVER['REMOTE_ADDR']."' , '".JRequest::getVar('fullname','', 'post', 'string', '' )."' , '".JRequest::getVar('firstname','', 'post', 'string', '' )."' , '".JRequest::getVar('middlename','', 'post', 'string', '' )."' , '".JRequest::getVar('lastname','', 'post', 'string', '' )."' , '".JRequest::getVar('addressa','', 'post', 'string', '' )."' , '".JRequest::getVar('addressb','', 'post', 'string', '' )."' , '".JRequest::getVar('city','', 'post', 'string', '' )."' , '".JRequest::getVar('state','', 'post', 'string', '' )."' , '".JRequest::getVar('zipcode','', 'post', 'string', '' )."' WHERE 'uid'='$uid'");" );
if (!$database->query()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>
";
}
?>
I got:
Parse error: syntax error, unexpected '>' in /home/laborat2/public_html/lcs1/components/com_chronocontact/chronocontact.php(525) : eval()'d code on line 7<br><br>Post edited by: slashchuck, at: 2008/03/18 05:12
Sure, you have extra - " - after the $uid
Make sure the SQL statement is correct too!
Cheers
Max
Make sure the SQL statement is correct too!
Cheers
Max
Max,
Thanks for the quick response.
I removed the extra ", and I no longer get any error messages. However the data is no longer being saved to the database.
Any ideas?
Basically I would like to display a form and allow them to change some data like if their address changed. That is why I'd like to use the "Update" as opposed to the original "Insert Into" I am having a rough time with the SQL syntax. Can you assist?
Thanks,
Chuck
<?php
$database =& JFactory::getDBO();
$database->setQuery( "UPDATE #__chronoforms_8 VALUES (
'' , '". date('Y-m-d')." - ".date("H:i:s")."', '".$_SERVER['REMOTE_ADDR']."' , '".JRequest::getVar('fullname','', 'post', 'string', '' )."' , '".JRequest::getVar('firstname','', 'post', 'string', '' )."' , '".JRequest::getVar('middlename','', 'post', 'string', '' )."' , '".JRequest::getVar('lastname','', 'post', 'string', '' )."' , '".JRequest::getVar('addressa','', 'post', 'string', '' )."' , '".JRequest::getVar('addressb','', 'post', 'string', '' )."' , '".JRequest::getVar('city','', 'post', 'string', '' )."' , '".JRequest::getVar('state','', 'post', 'string', '' )."' , '".JRequest::getVar('zipcode','', 'post', 'string', '' )."' WHERE 'uid'='$uid');" );
if (!$database->query()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>
";
}
?>
Thanks for the quick response.
I removed the extra ", and I no longer get any error messages. However the data is no longer being saved to the database.
Any ideas?
Basically I would like to display a form and allow them to change some data like if their address changed. That is why I'd like to use the "Update" as opposed to the original "Insert Into" I am having a rough time with the SQL syntax. Can you assist?
Thanks,
Chuck
<?php
$database =& JFactory::getDBO();
$database->setQuery( "UPDATE #__chronoforms_8 VALUES (
'' , '". date('Y-m-d')." - ".date("H:i:s")."', '".$_SERVER['REMOTE_ADDR']."' , '".JRequest::getVar('fullname','', 'post', 'string', '' )."' , '".JRequest::getVar('firstname','', 'post', 'string', '' )."' , '".JRequest::getVar('middlename','', 'post', 'string', '' )."' , '".JRequest::getVar('lastname','', 'post', 'string', '' )."' , '".JRequest::getVar('addressa','', 'post', 'string', '' )."' , '".JRequest::getVar('addressb','', 'post', 'string', '' )."' , '".JRequest::getVar('city','', 'post', 'string', '' )."' , '".JRequest::getVar('state','', 'post', 'string', '' )."' , '".JRequest::getVar('zipcode','', 'post', 'string', '' )."' WHERE 'uid'='$uid');" );
if (!$database->query()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>
";
}
?>
Hi Chuck,
I guess you will need to test with the SQL query completed with real static values first so you can get where the error isπ
google "SQL update statement syntax" for more info too!
Cheers
Max
I guess you will need to test with the SQL query completed with real static values first so you can get where the error isπ
google "SQL update statement syntax" for more info too!
Cheers
Max
This topic is locked and no more replies can be posted.
