Page 1 of 1

Input Data is failed

Posted: Mon Jul 09, 2007 3:59 pm
by ayoksus
Hi,

I have php form script, and the last code is like this

Code: Select all

$input=mysql_query("INSERT INTO news(category,username,title,headline) 
	VALUES ('$category','$username','$title','$headline')");

if($input)
	{
		echo "Input data is success<BR>";
		echo "<a href=form_news.php>Add more news</a>";
		echo "<a href=logout.php>Logout</a>";
	}
	else
	{
		echo "Input data is failed";
	}
I've got an "input data failed" message. So how can I fix it? Where is my mistake?

Thx,
ayoksus

Posted: Mon Jul 09, 2007 4:23 pm
by Gente
What error have you got?
Try to debug your script with following code:

Code: Select all

$result = mysql_query("INSERT INTO news(category,username,title,headline) VALUES ('$category','$username','$title','$headline')");
if (!$result) {
    die('Invalid query: ' . mysql_error());
}

Posted: Mon Jul 09, 2007 5:23 pm
by ayoksus
thx Gente,

It helps.

rgds,
ayoksus