new error:
Error in query: Unknown column '$post' in 'field list'
ill escape that too, thanks for that
current code:
PHP Code:
<?php
// If the form hasent been filled and submited, then display it.
if (!isset ($_POST['submit'])) {
?>
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
<div align="center"><textarea name="post" rows="15" style="width:600px;">Type your post here.</textarea><br />
<input name="submit" type="submit" value="Post">
</div>
</form>
<?php
// End form.
}
// If the post form has been submited, add it to the database and show all posts.
if (isset ($_POST['submit'])) {
// Open connection.
$connection = mysql_connect(localhost, shadowte_shadow, tikicat) or die ('Unable to connect!');
// Select database.
mysql_select_db(shadowte_cmstest1) or die ('Unable to select database!');
// Get the post that the user submited...
$post = $_POST['post'];
// Remove slashes if Magic Quotes are on.
if(get_magic_quotes_gpc())
{
$post = stripslashes($post);
}
// Make the post MySQL safe.
$post = mysql_real_escape_string($post);
// Add this post to the database.
$addpost = 'INSERT INTO posts (input) VALUES ('.$post.')';
// Execute addition.
mysql_query($addpost) or die ('Error in query: '.mysql_error());
// Close connection.
mysql_close($connection);
// End posts.
}
?>
and back to this error:
Error in query: 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 '`input` VALUES ('Type your post here.')' at line 1
Bookmarks