forum trouble

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

sophie
Forum Newbie
Posts: 10
Joined: Wed May 23, 2012 1:17 am

Re: forum trouble

Post 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
TylerH4
Forum Newbie
Posts: 10
Joined: Sat May 26, 2012 8:45 pm

Re: forum trouble

Post 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')";
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: forum trouble

Post 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
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
sophie
Forum Newbie
Posts: 10
Joined: Wed May 23, 2012 1:17 am

Re: forum trouble

Post 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
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: forum trouble

Post 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
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
sophie
Forum Newbie
Posts: 10
Joined: Wed May 23, 2012 1:17 am

Re: forum trouble

Post 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]
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: forum trouble

Post 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?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply