Pleas help
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:
<input type='text' name='title'><p>
Body:
<textarea rows="6"cols='35' name = 'body' ></textarea>
<p>
<input type="submit" name='post' value='Adauga' >
<hr>
dan1992
Junior Poster in Training
65 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0
Do this -
if (isset($title) && isset($body))
network18
Practically a Master Poster
619 posts since Sep 2009
Reputation Points: 29
Solved Threads: 76
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());
Froger93
Junior Poster in Training
74 posts since Sep 2009
Reputation Points: 11
Solved Threads: 6
:( thx for this but, is the same problem
dan1992
Junior Poster in Training
65 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0
Parse error: syntax error, unexpected T_VARIABLE in D:\Dan\web\bundle\xampp\xampp\htdocs\news\post.php on line 16
dan1992
Junior Poster in Training
65 posts since Oct 2009
Reputation Points: 10
Solved Threads: 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:
<input type='text' name='title' id="title"><p>
Body:
<textarea rows="6"cols='35' name = 'body' id="body" ></textarea>
<p>
<input type="submit" name='submit' value='Adauga' >
<hr>
network18
Practically a Master Poster
619 posts since Sep 2009
Reputation Points: 29
Solved Threads: 76
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:
<input type='text' name='title' id="title">
Body:
<textarea rows="6"cols='35' name = 'body' id="body" ></textarea>
<input type="submit" name='submit' value='Adauga' >
</Form>
</body>
</html>
network18
Practically a Master Poster
619 posts since Sep 2009
Reputation Points: 29
Solved Threads: 76
bu this can be the problem with data base ?
dan1992
Junior Poster in Training
65 posts since Oct 2009
Reputation Points: 10
Solved Threads: 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
dan1992
Junior Poster in Training
65 posts since Oct 2009
Reputation Points: 10
Solved Threads: 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
dan1992
Junior Poster in Training
65 posts since Oct 2009
Reputation Points: 10
Solved Threads: 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.
Froger93
Junior Poster in Training
74 posts since Sep 2009
Reputation Points: 11
Solved Threads: 6
the line 14 -
$date = date ("Y-m-d")
doesn't end with semicolon (;).
network18
Practically a Master Poster
619 posts since Sep 2009
Reputation Points: 29
Solved Threads: 76
lol, surprised you didn't spot that one form a mile off :P
Froger93
Junior Poster in Training
74 posts since Sep 2009
Reputation Points: 11
Solved Threads: 6