Can someone let me know what's wrong on my small sql query sintax?

Is also there in whatever way on mysql to obtain the exact error from 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>

mysql_error (docs) will return the final error in the database.

It appears much like your code will execute the query two times, incidentally. Just one call to $db->query() ought to be used.

So far as what, contrary is wrong, that's hard to say. I don't use whatever apparent errors, however i do question about getting away the values you are using within the query. Begin to see the paperwork for mysql_real_escape_string - if any one of individuals values contain an apostrophe, your query could be damaged.

I additionally visit a spelling error, "acknoledge" is typed "acknowledge", therefore if the area is typed properly within the database, then you will see an issue with the misspelling within the query. On that same note, a number of your fields use underscores_names where some use camelCase names. You are just pleading for any typo such as this. Play one naming convention or another, and it consistent. In case your area is known as employeeNumber and also you use employee_number or EmployeeNumber, the query will fail. Choose a naming convention and stay with it which means you aren't speculating any time you write a question!

I believe maybe it's a few things, there is however a spelling error with "acknowledge". It's typed improperly within the column listing of the card inserts, along with the variable you utilize within the INSERT statement. It's typed properly whenever you assign that variable.

Edit: Labored through this in talk to OP. The issue was this code had been used like a snippet in the Joomla article. The form's publish needed to visit $_SERVER['REQUEST_URI'] to publish to the correct place.

mysqli_error() or mysql_error().

With no error and table structure is a little hard but...

Maybe you are attempting to place an int datatype like a string, for instance user_id. Take away the '' when utilizing number values, since they're not strings.

For instance:

INSERT INTO table_name
(id_field, string_field)
VALUES
({$id_value}, '{$string_value}');