0

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>

Edited by Ezzaral: Added [code] [/code] tags. Please use them to format any code that you post.

4
Contributors
13
Replies
14
Views
7 Years
Discussion Span
Last Post by Froger93
0

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());

Edited by Froger93: n/a

0
$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

0

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

0

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>
0

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>

Edited by network18: n/a

0

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

0

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

0
$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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.