it say theat he error is in line 16 i dont no wat error is :( plea help

<?php

  if($_POST['post'])
{

//gat data
$title = $_POST['title'];
$body = $_POST['body'];
//chec fot existance
if ($title&&$body)
{
mysql_connect("localhost","root","")or die(mysql_error());
mysql_select_db("dan")or die (mysql_error());

$date = date ("Y-m-d")
//adaugarea inoutati
$insert = mysql_query("INSERT INTO n VALUES ('','$title','$body','$date')") or die (msql_error());
die ("Noutatea dumneavoastra nu a fostr adaugata");
}
else
   echo "Intrduceti va rog Informatia<p>";
}


?>
<Form action="post.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='Adauga' >
      <hr>

Recommended Answers

All 13 Replies

Do this -
if (isset($title) && isset($body))

Also: $insert = mysql_query("INSERT INTO n VALUES ('','$title','$body','$date')") or die (msql_error()); Should be: $insert = mysql_query("INSERT INTO n VALUES ('','$title','$body','$date')") or die (mysql_error());

$date = date ("Y-m-d")

The date function needs a timestamp argument as the second argument and you should terminate this line.

date("argument 1",time());

Google for more info on how to use the date function

:( thx for this but, is the same problem

Parse error: syntax error, unexpected T_VARIABLE in D:\Dan\web\bundle\xampp\xampp\htdocs\news\post.php on line 16

use the code tags, its not even clear which is the line16.
and try this -

<?php

if(isset($_POST['submit']) && $_POST['submit'] != '' )
{
	//gat data
	$title = $_POST['title'];
	$body = $_POST['body'];
	//chec fot existance
	if ($title != '' || $body != '')
	{
		mysql_connect("localhost","root","")or die(mysql_error());
		mysql_select_db("dan")or die (mysql_error());
		
		$date = date ("Y-m-d")
		//adaugarea inoutati
		$insert = mysql_query("INSERT INTO n VALUES ('','$title','$body','$date')") or die (mysql_error());
		die ("Noutatea dumneavoastra nu a fostr adaugata");
	}
	else{ echo "Either title or body is blank";}
}
else
	echo "Intrduceti va rog Informatia<p>";
}


?>
<Form action="" method='post'>
Title:<br>
<input type='text' name='title' id="title"><p>
Body:<br>
<textarea rows="6"cols='35' name = 'body' id="body" ></textarea>
<p>
<input type="submit" name='submit' value='Adauga' >
<hr>

Ignore the previous post, your code there did not have proper html even.

<?php

if(isset($_POST['submit']) && $_POST['submit'] != '' )
{
	//gat data
	$title = $_POST['title'];
	$body = $_POST['body'];
	//chec fot existance
	if ($title != '' || $body != '')
	{
		mysql_connect("localhost","root","")or die(mysql_error());
		mysql_select_db("dan")or die (mysql_error());
		
		$date = date ("Y-m-d")
		//adaugarea inoutati
		$insert = mysql_query("INSERT INTO n VALUES ('','$title','$body','$date')") or die (mysql_error());
		die ("Noutatea dumneavoastra nu a fostr adaugata");
	}
	else{ echo "Either title or body is blank";}
}
else
	echo "Intrduceti va rog Informatia<p>";
}


?>
<html>
<title></title>
<body>
<Form action="" method='post'>
Title:<br>
<input type='text' name='title' id="title">
Body:<br>
<textarea rows="6"cols='35' name = 'body' id="body" ></textarea>
<br>
<input type="submit" name='submit' value='Adauga' >
</Form>
</body>
</html>

bu this can be the problem with data base ?

this can be a problem with data base becos i tried theat wat you writh an is the same error :((
sry for my engles i'm learning englesh just 3 eares

this can be a problem with data base becos i tried theat wat you writh an is the same error :((
sry for my engles i'm learning englesh just 3 eares

$date = date ("Y-m-d")
		//adaugarea inoutati

The date function is missing a closing semi-colon.

The script should work, obviously like most scripts it could do with a little tidy.

If you make sure all MySQL table names and column names are encapsed in ` (left of the 1 key) and all data is encapsed in ' then your queries are simple and fool proof.

the line 14 -
$date = date ("Y-m-d")
doesn't end with semicolon (;).

lol, surprised you didn't spot that one form a mile off :P

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.