Input Data is failed

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

Post Reply
ayoksus
Forum Newbie
Posts: 14
Joined: Tue Feb 13, 2007 2:51 pm

Input Data is failed

Post 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
User avatar
Gente
Forum Contributor
Posts: 252
Joined: Wed Jun 13, 2007 9:43 am
Location: Ukraine, Kharkov
Contact:

Post 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());
}
ayoksus
Forum Newbie
Posts: 14
Joined: Tue Feb 13, 2007 2:51 pm

Post by ayoksus »

thx Gente,

It helps.

rgds,
ayoksus
Post Reply