Page 2 of 2

Re: forum trouble

Posted: Tue May 29, 2012 10:01 pm
by sophie
this :
SELECT MAX(a_id) AS Maxa_id FROM forum_answer1Incorrect integer value: '' for column 'question_id' at row 1
:banghead:

if i remove the echo $sql..this will be the error
1Incorrect integer value: '' for column 'question_id' at row 1

Re: forum trouble

Posted: Wed May 30, 2012 8:32 am
by TylerH4
That error is coming from the INSERT SQL query. It is trying to insert ID as a string. Remove the quotes around $id and see what happens:

Code: Select all

$sql2="INSERT INTO forum_answer(question_id,a_id,a_name,a_email,a_answer,a_datetime)
        VALUES($id,'$Max_id','$a_name','$a_email','$a_answer','$datetime')";

Re: forum trouble

Posted: Thu May 31, 2012 9:43 am
by social_experiment
Is 'question_id' an auto-incrementing column?
http://www.webmasterworld.com/forum88/13136.htm
This url may shed some light on the problem

Re: forum trouble

Posted: Thu May 31, 2012 10:13 pm
by sophie
hey thanks tylerH4 i remove the quotes around $id and this is what happens

1You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ','1','claire','@yahoo','what?? ','01/06/12 11:17:24')' at line 2
social experiment my question_id is not auto increment.. but the default value is null

:banghead:

https://www.facebook.com/photo.php?fbid ... =3&theater

that's my forum_answer table

Re: forum trouble

Posted: Fri Jun 01, 2012 12:48 am
by social_experiment
The default value could be the problem; I created a table and set one of the columns to INT(4) and the default value of the column to 'NULL' and got an error message about it, before i inserted any data. Once i set the default value to 'None' I also tried passing 0, '' or '0' to the column and received a similar error to what you are currently receiving

Re: forum trouble

Posted: Wed Jun 06, 2012 9:48 pm
by sophie
so i will change the default value to "null"? .. i will give it a try..

nothing changes :banghead:

the question_id will be the id that i choose to reply to, so that could not be a null value?

i think it didn't read this code

Code: Select all

$id=$_POST['id'];
when i run this code it should have 6 value that will insert into my database but the error is trying to put only 5 values..it didnt read the value of my $id

Code: Select all

$sql2="INSERT INTO forum_answer(question_id,a_id,a_name,a_email,a_answer,a_datetime)
	VALUES($id,'$Max_id','$a_name','$a_email','$a_answer','$datetime')";
	$result2=mysql_query($sql2) or die (mysql_error());
so the same error again

[text]
1You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ','1','mklkl','kjkl','lkjlk ','07/06/12 10:55:42')' at line 2
[/text]

Re: forum trouble

Posted: Thu Jun 07, 2012 12:23 am
by social_experiment
sophie wrote:so i will change the default value to "null"? .. i will give it a try..
No the default value shouldn't be null;
social_experiment wrote:The default value could be the problem; I created a table and set one of the columns to INT(4) and the default value of the column to 'NULL' and got an error message about it, before i inserted any data.
What value do you get for $id ($_POST['id']) if echoed to the browser?