0

Alright, maybe I'm having a brain cramp this late at night, but my code is not working, and I have no idea why. Any help? This is simply being used for me right now, so yes, I'm pulling straight from the $_POST.

<?php
session_start();
if($_SESSION['id'] != 5)
{
	echo "NOT ALLOWED";
}
else
{
include('connect.php');
$title = $_POST['title'];
$content = $_POST['content'];

$sql = "INSERT INTO updates (id, title, date_posted, content)
VALUES (LAST_INSERT_ID(), ".$title.", CURDATE(), ".$content."";
}


mysql_query($sql);

?>
2
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by ZethSchlenker
0

assuming that id is an AUTO_NUMBER and title & content are of text data type, try:

$sql = "INSERT INTO updates (id, title, date_posted, content)
VALUES ( NULL, '".$title."', Now(), '".$content."'";
0

Hm, I just tried your suggestion, and it's still not working.
The only other page before that is:

<form action='add_check.php' method='post'>
	Title: <input type='text' name='title'  /><br>
	Content: <textarea name='content' cols='100' rows='25'></textarea> 
	<input type='submit' name='add' />
	</form>

But that's just the simple form.

0

The VALUES clause is missing the closing parenthesis:

$sql = "INSERT INTO updates (id, title, date_posted, content)
VALUES ( NULL, '".$title."', Now(), '".$content."')";
This question has already been answered. 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.