Can someone tell me what is wrong on my sql query sintax?
Also is there any way on mysql to get the exact error of the query?
<?php
// If the constant _JEXEC is not defined, quit now.
// This stops this script from running outside of the system.
defined( '_JEXEC' ) or die( 'Restricted access' );
?>
<script type="text/javascript" language="javascript">
function proceed()
{
check = document.getElementById('checkToProceed');
proceedButton = document.getElementById('proceedButton');
if (check.checked)
{
proceedButton.disabled = false;
}
else
{
proceedButton.disabled = true;
}
}
</script>
<?php
if ($_POST['proceedButton'] != '') {
$user = JFactory::getUser();
$id = $user->get('id');
$name = $user->get('name');
$username = $user->get('username');
$department = $user->get('department');
$vardate = date("m/d/y : H:i:s", time());
$acknowledge = 1;
$courseTitle = $mainframe->getPageTitle();
/***************************************/
$db = &JFactory::getDBO();
$query = "INSERT INTO `jos_jquarks_users_acknowledge`(course_name)VALUES('hello')";
$db->setQuery($query);
$db->query();
echo mysql_error ();
if($db->getErrorNum()) {
JError::raiseError( 500, $db->stderr());
}
}
?>
<form name="quiz_info" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="checkbox" id="checkToProceed" name="checkToProceed" onclick="proceed();" />
<label for="checkToProceed">
<?php echo JText::_('I have Read and Acknowledge the procedure'); ?>
</label>
<input id="proceedButton" name="proceedButton" disabled="true" value="Acknowledge" type="submit" />
<input type="hidden" name="layout" value="default" /> <?php echo JHTML::_( 'form.token' ); ?>
</form>
I think it could be a couple of things, but there’s a spelling error with “acknowledge”. It’s spelled incorrectly in the column list of the inserts, as well as the variable you use inside the
INSERTstatement. It’s spelled correctly when you assign that variable.Edit: Worked through this in chat with OP. The problem was that this code was being used as a snippet inside a Joomla article. The form’s post had to go to
$_SERVER['REQUEST_URI']to post back to the proper place.