how to Insert form data in table i have an enquiry form and submitting the form using jquery/ajax method. 

$.ajax({
          url:enquiry.php


I am able to insert records into database table using php mysql_query. When i use db_query in "enquiry.php" page, i am getting errors. 

   Call to undefined function db_query()


i want to know how to use db_query to insert records in database table.
For that function to be available from outside Drupal, you need to first bootstrap Drupal. This means that, with Drupal 7, the first lines of enquiry.php needs to be the following ones.

define('DRUPAL_ROOT', getcwd());

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);


I assume the enquiry.php file is in the same directory containing the index.php file that comes with Drupal.

I would rather suggest you to read the following questions, though:


Are there cases where a third-party module would need to use its own file similar to xmlrp.php, cron.php, or authenticate.php?
How should I implement hook_menu()?