|
Parse Error
First off, great articles. I've really enjoyed reading them.
But, when I went to newArticle.php, I got an error:
Parse error: parse error, unexpected T_STRING in /www/n/name/htdocs/folder/cmsadmin/newArticle.php on line 7
I'm not sure what the problem is.
Here's the file:
<html>
<head>
<title>Submit New Article</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<?php
require_once("../includes/DbConnector.php");
// Check whether a form has been submitted. If so, carry on
if ($HTTP_POST_VARS){
// Create an instance of DbConnector
$connector = new DbConnector();
// IMPORTANT!! ADD FORM VALIDATION CODE HERE - SEE THE NEXT ARTICLE
// Create an SQL query (MySQL version)
$insertQuery = "INSERT INTO cmsarticles (title,tagline,section,thearticle) VALUES (".
"'".$HTTP_POST_VARS['title']."', ".
"'".$HTTP_POST_VARS['tagline']."', ".
$HTTP_POST_VARS['section'].", ".
"'".$HTTP_POST_VARS['thearticle']."')";
// Save the form data into the database
if ($result = $connector->query($insertQuery)){
// It worked, give confirmation
echo '<center><b>Article added to the database</b></center><br>';
}else{
// It hasn't worked so stop. Better error handling code would be good here!
exit('<center>Sorry, there was an error saving to the database</center>');
}
}
?>
<body>
<form name="form1" method="post" action="newArticle.php">
<p> Title:
<input name="title" type="text" id="title">
</p>
<p> Tagline:
<input name="tagline" type="text" id="tagline">
</p>
<p> Section:
<input name="section" type="text" id="section">
</p>
<p> Article:
<textarea name="thearticle" cols="50" rows="6" id="thearticle"></textarea>
</p>
<p align="center">
<input type="submit" name="Submit" value="Submit">
</p>
</form>
</body>
</html>
thanks,
Sam
|