Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Hi everyone,
I am trying to set up a little news management system and all is fine except for this one error I get in add.php:
The Code:Code: Select all
<?php
//The following code is the PHP form handling application.
//Connecting to the MySQL database
require('http://www.jayreilly.net/dbconnect.php');
//The current date.
$today = date('n/j/y');
if($_POST['submit']) {
//Simplifying the variables.
$title = $_POST['title'];
$author = $_POST['author'];
$date = $_POST['date'];
//trim() strips white space from the beginning and end of a line.
$date = trim($date);
$content = $_POST['content'];
//Checks for empty fields or invalid date.
if((empty($title)) OR (empty($author)) OR (empty($date)) OR (empty($content))) {
echo "<center><strong>Please fill in all fields!</strong></center>
} else {
//explode() separates the date by the '/' character and outputs it to an array.
$explode_date = explode('/', $date);
//checkdate() returns FALSE if the date is invalid.
$check_date = checkdate($explode_date[0], $explode_date[1], $explode_date[2]);
if($check_date == false) {
echo "<center><strong>Invalid date entered!</strong></center>";
} else {
//htmlspecialchars() converts special characters into HTML entities.
$title = htmlspecialchars($title);
$author = htmlspecialchars($author);
//The MySQL query which will insert content into the table.
$query = "INSERT INTO news (ID, title, author, date, content) VALUES ('', '$title', '$author', '$date', '$content')";
//Executing the query with mysql_query().
mysql_query($query) or die(mysql_error());
echo "<center><strong>News item added!</strong></center>";
}
}
}
//Closing the connection.
mysql_close($connection);
?>
<form method="post" action="http://www.jayreilly.net/add.php">
<table align="center">
<tr><td align="right">Title:</td><td><input type="text" name="title" maxlength="250" /></td></tr>
<tr><td align="right">Author:</td><td><input type="text" name="author" maxlength="250" /></td></tr>
<tr><td align="right">Date:</td><td><input type="text" name="date" value="<?php echo "$today"; ?>" maxlength="10" /></td></tr>
<tr><td align="right">Content:</td><td><textarea name="content" cols="50" rows="10"></textarea></td></tr>
<tr><td> </td><td><input type="submit" name="submit" value="Submit" /><input type="reset" name="reset" value="Reset" /></td></tr>
</table>
</form>The error:
Parse error: syntax error, unexpected '>' in /hsphere/local/home/james595/jayreilly.net/add.php on line 28
Could anyone shed any light on this as I cannot see the parse error myself!
Pimptastic | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]