AmenKa
07-29-2008, 10:56 PM
Hi, I wrote a script that grabs a user's text and adds it to a database... or so I thought I did.
When it runs, I get a MySQL error:
Error in query: Unknown column 'Type your post here.' in 'field list'
Any help?
PHP File:
<?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'];
// Add slashes if Magic Quotes are off. (they should be)
if(!get_magic_quotes_gpc())
{
$post = addslashes($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());
// End posts.
}
?>
Example:
http://www.shadowtechstudios.net/shadowtechstudios.net/projects/postsystem/0.0.1.php
When it runs, I get a MySQL error:
Error in query: Unknown column 'Type your post here.' in 'field list'
Any help?
PHP File:
<?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'];
// Add slashes if Magic Quotes are off. (they should be)
if(!get_magic_quotes_gpc())
{
$post = addslashes($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());
// End posts.
}
?>
Example:
http://www.shadowtechstudios.net/shadowtechstudios.net/projects/postsystem/0.0.1.php