I am obtaining the following error while performing the qurey,

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''income-table' ('id' ,'userid' ,'net-salary' ,'net-salary-source' ,'interest-inc' at line 1

I am while using following query line ,

$sql = "INSERT INTO 'income-table' ('id' ,'userid' ,'net-salary' ,'net-salary-source' ,'interest-income' ,'interest-income-source' ,'dividends-income' ,'dividends-income-source' ,'gift-income' ,'gift-income-source' ,'reimbursements-income' ,'reimbursements-income-source' ,'savings-transfer-income' ,'savings-transfer-income-source' ,'other-income' ,'other-income-source' ,'date-time')VALUES ('2', '11', '11', 'debit1', '11', 'debit1', '11', 'debit1', '11', 'debit1', '11', 'debit1', '11', 'debit1', '11', 'debit1',CURRENT_TIMESTAMP)";

if(mysql_query($sql)  or die(mysql_error()))
    {
        //loadTodayData();
        echo "success1";
    }

There's not a problem in connection. Please guide me.

Thanks.

You shouldn't use single-quotes arround the fields names : individuals are utilized arround string values.

Rather, if you wish to safeguard your fields names (and table names), you have to use backticks : `


Essentially, your query could seem like this :

$sql = "INSERT INTO `income-table` (`id` ,`userid` , ... )
    VALUES ('2', '11', ...)";

To not use single quote you should use the backtick ` and take away the only quote from area names.

Single or Double quotes shouldn't be combined with table title and area names you should use backtick `

$sql = "INSERT INTO `income-table` (`id` ....

try that one:

$sql = "INSERT INTO `income-table` (`id` ,`userid` ,`net-salary` ,`net-salary-source` ,`interest-income` ,`interest-income-source` ,`dividends-income` ,`dividends-income-source` ,`gift-income` ,`gift-income-source` ,`reimbursements-income` ,`reimbursements-income-source` ,`savings-transfer-income` ,`savings-transfer-income-source` ,`other-income` ,`other-income-source` ,`date-time`) VALUES ('2', '11', '11', 'debit1', '11', 'debit1', '11', 'debit1', '11', 'debit1', '11', 'debit1', '11', 'debit1', '11', 'debit1', now())";

It's invalid to make use of quotes for table title and column names.

Guideline, table and column selectors although 'string' is perfect for these.

UPDATE table SET column = 'val', column2 = column2+1 WHERE column = 'value'