Database not holding my posts

My database is not holding my posts on my PHP script. I have it echoing back on the website that the local host and database are connected fine. It must be something with the table??? Do you see anything wrong with the table? Am I missing something?

Thanks in advance everyone

Michael:)


<?php
if($_POST)
{
$name=$_POST['name'];
$email=$_POST['email'];
$comment=$_POST['comment'];

$lowercase = strtolower($email);
  $image = md5( $lowercase );
  
mysql_connect("localhost", "-------", "-------") or die(mysql_error());
echo "";
mysql_select_db("-------") or die(mysql_error());
echo "";

mysql_query("INSERT INTO CREATE TABLE comments (name,email,comment) VALUES ('$name','$email','$comment') ") ;

}

else { }

?>

I created the table it warns me NO Index Found should I make the com_id first line the index?

which comments? - I assume you mean the comments entered in a form somewhere.

If so, what I normally do is, on every page load, get the row of data from the database for that page and then set each value in the results set from the database to the default value for the appropriate input element.

eg.

 
<input type="text" name="txtFname" value="<?php echo $row['fldFname']; ?>" />

Ok great folks its now working in the database.
Thanks everyone.

New Problem -----the comments are not staying on each refresh of the page…

what r937 said :slight_smile:

the word CREATE doesn’t belong

edit: oh, wait… from the phpmyadmin snapshot, it looks like [COLOR="Red"]CREATE TABLE comments[/COLOR] – yes, that whole thing, with spaces included – is the name of the table

drop your table and create it again, okay?

:slight_smile:

I took the comments part out which i missed.

Still making me have a headache.

No working

the table name in

INSERT INTO posts comments (name,email,comment)…

doesn’t match the table name in your screenshot image.

make sure that the table name in the INSERT statement matches the table name in your database.

I have a few more lines below this script but I doubt those are causing the problem. The posts are going onto the page but each refresh shows they done hold and the database has nothing.

I appreciate peoples help. I hope we can solve this mystery.

Michael


<?php
if($_POST)
{
$name=$_POST['name'];
$email=$_POST['email'];
$comment=$_POST['comment'];

$lowercase = strtolower($email);
  $image = md5( $lowercase );
  
mysql_connect("localhost", "-----", "-------") or die(mysql_error());
echo "";
mysql_select_db("-------") or die(mysql_error());
echo "";

mysql_query("INSERT INTO posts comments (name,email,comment) VALUES ('$name','$email','$comment') ") ;

}

else { }

?>
<li class="box">
<img src="/images/comment.png?gravatar_id=<?php echo $image; ?>" style="float:left; width:80px; height:71px; margin-right:20px"/><span style="font-size:16px; color:#663399; font-weight:bold"> <?php echo $name;?></span> <br /><br />

<?php echo $comment; ?>
</li>



<?php
if($_POST)
{
$name=$_POST['name'];
$email=$_POST['email'];
$comment=$_POST['comment'];

$lowercase = strtolower($email);
  $image = md5( $lowercase );
  
mysql_connect("localhost", "--------", "------") or die(mysql_error());
echo "";
mysql_select_db("-----") or die(mysql_error());
echo "";

mysql_query("INSERT INTO posts comments (name,email,comment) VALUES ('$name','$email','$comment') ") ;

}

else { }

?>


Yeah that was the table name CREATE TABLE comments. I will drop the table and redo it. What should I call it? Will it make a difference?

Thanks

SELECT * FROM CREATE TABLE comments WHERE 1

What do you see wrong with it Kalon?

INSERT INTO CREATE TABLE comments (name,email,comment) VALUES (‘$name’,‘$email’,‘$comment’)

This doesn’t look right to me.