i got a problem with my post script. Its giving a syntax error, what i cannot found since yesterday, may i am just blind or something else. But where is the error?
Problem:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1')' at line 1
functions.php
function addPost($pName, $pAuthor, $pContent, $pCat = null) {
$query = mysql_query("INSERT INTO cm_posts VALUES(null,'$pName','$pAuthor','$pContent,'$pCat')") or die(mysql_error());
}
doAddPost.php
<?php
include('./includes/functions.php');
if(isset($_POST['submit'])) {
if(isset($_POST['PostName'])) {
if(isset($_POST['PostContent'])) {
addPost($_POST['PostName'], $_POST['PostAuth'], $_POST['PostContent'], $_POST['postCategory']);
header("Location: posts.php");
} else {
echo "Please edit it Marcell";
}
} else {
echo "please set a post name!";
include('addpost.php');
}
} else {
header("Location: addpost.php");
}
?>
addpost.php
<?php include_once("./includes/functions.php"); ?>
<form action="doAddPost.php" method="post">
<table>
<tr>
<td><label for="PostName">Name</label></td><td><input type="text" name="PostName" /></td>
</tr>
<tr>
<td><label for="PostAuth">Ath</label></td><td><input type="text" name="PostAuth" /></td>
</tr>
<tr>
<td><label for="PostContent">Content</label></td>
<td><textarea name="PostContent"></textarea></td>
</tr>
<label for="postCategory">Category</label>
<select class="form-control" name="postCategory">
<?php
$result = mysql_query("SELECT * FROM cm_categories");
while($cat = mysql_fetch_assoc($result)) {
?>
<option value="<?php echo $cat['ID']; ?>"><?php echo $cat['Title']; ?></option>
<?php
}
?>
</select>
<tr>
<td colspan="2"><input type="submit" name="submit" /></td>
</tr>
</table>
</form>
Any idea?