0

I have got this statement:

   $query="INSERT INTO error_report(task_id,url_is_route, forbidden_word, google_host_fail, google_cache_fail, google_title_fail, google_element_fail, robots_noindex_nofollow, xrobots_noindex_nofollow, title_fetch_warn, h1_fail,h2_fail,h3_fail ,h1_warn ,h2_warn, h3_warn)
         VALUES (".$this->task_id.",0,0,0,0,0,0,0,0,0,0,0,0,0,0)";   


mysql_query($query) or die(mysql_error()); 

I get this:

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 '0,0,0,0,0,0,0,0,0,0,0,0,0,0)' at line 2

Where does the problem lie?

UPDATE

$query="INSERT INTO error_report(task_id,url_is_route, forbidden_word, google_host_fail, google_cache_fail, google_title_fail, robots_noindex_nofollow, xrobots_noindex_nofollow, title_fetch_warn, h1_fail,h2_fail,h3_fail ,h1_warn ,h2_warn, h3_warn)
             VALUES ('".$this->task_id."','0','0','0','0','0','0','0','0','0','0','0','0','0','0')"; 

Now I get:

Incorrect integer value: '' for column 'task_id' at row 1

6
  • I think you need to quote each entry. Like '".$this->task_id."', '0' Commented Apr 30, 2012 at 6:14
  • You forgot the quotes everywhere Commented Apr 30, 2012 at 6:14
  • 1
    @DmitryMakovetskiyd: Can you output the value of $query prior to its execution and show us? Commented Apr 30, 2012 at 6:16
  • 1
    I think you've forgotten one zero for the values (if i've counted correctly, you have 16 fields and 15 values)... Oh, and what's the value of $this->task_id? Commented Apr 30, 2012 at 6:16
  • @Dmitry Have you actually tried with quotes? If not please first try it. This a very common problem. Commented Apr 30, 2012 at 6:19

4 Answers 4

2
  1. Use quotes
  2. You are trying to update 16 columns but entering only 15 values. Correct that.
Sign up to request clarification or add additional context in comments.

2 Comments

Could you please tell me of what 'type' is the column task_id in database and what actually is the value of $this->task_id ?
try to put a hardcoded value instead of $this->task_id in the query. If it works then may be $this->task_id is empty
2

Incorrect integer value: '' for column 'task_id' at row 1

$this->task_id is empty and does not contain 116 as you suspect.

Comments

1

How about just setting Default Value of fields to 0 and doing:


$query="INSERT INTO error_report(task_id) VALUES (".$this->task_id.")";   

3 Comments

Column count doesn't match value count at row 1
use exactly one field name with one value for the field in your insert statement like i mentioned in answer above... and that should solve the error
I have one field that is autoincremented
1

Check these

  1. $this->task_id contains the value and not it is empty
  2. $this->task_id has an integer value in it or any characters. I think the column is int, so if it contains non integer values it throws an error

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.