php errors..
Posted: Wed Apr 20, 2011 11:47 am
hello guys.. im need to solve my problem here..
my first problem is, when im done with my php code, it will display this
"Notice: Undefined index: post in C:\xampp\htdocs\project\post.php on line 7" as my error..
and the second problem is, when i fill up the form in this php, will will display 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 ')' at line 1"
can anyone help me solve this problem..
here my php coding..
<html>
<h1>Post news</h1>
<hr>
<form action = 'posts.php' method = 'post'>
Title: <br>
<input type = 'text' name = 'title'><p>
Body: <br>
<textarea rows = '6' cols = '35' name = 'body'></textarea><p>
<input type = 'submit' name = 'post' value = 'Post this news' >
</form>
<hr>
<?php
if ($post = $_POST['post'])
{
//get data
$title = &$_POST ['title'];
$body = &$_POST ['body'];
//check existance
if ($title&&$body)
{
mysql_connect("localhost","root","") or die (mysql_error());
mysql_select_db("project") or die (mysql_error());
$date = date('y-m-d');
//insert data
$insert = mysql_query("INSERT INTO news VALUES('','$title','$body','$date',)") or die (mysql_error());
die ("Your news has been posted");
}
else
die ("Please fill out title and body");
}
?>
</html>
my first problem is, when im done with my php code, it will display this
"Notice: Undefined index: post in C:\xampp\htdocs\project\post.php on line 7" as my error..
and the second problem is, when i fill up the form in this php, will will display 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 ')' at line 1"
can anyone help me solve this problem..
here my php coding..
<html>
<h1>Post news</h1>
<hr>
<form action = 'posts.php' method = 'post'>
Title: <br>
<input type = 'text' name = 'title'><p>
Body: <br>
<textarea rows = '6' cols = '35' name = 'body'></textarea><p>
<input type = 'submit' name = 'post' value = 'Post this news' >
</form>
<hr>
<?php
if ($post = $_POST['post'])
{
//get data
$title = &$_POST ['title'];
$body = &$_POST ['body'];
//check existance
if ($title&&$body)
{
mysql_connect("localhost","root","") or die (mysql_error());
mysql_select_db("project") or die (mysql_error());
$date = date('y-m-d');
//insert data
$insert = mysql_query("INSERT INTO news VALUES('','$title','$body','$date',)") or die (mysql_error());
die ("Your news has been posted");
}
else
die ("Please fill out title and body");
}
?>
</html>