I have been trying to create a simple comments box by following tutorials online but I cant seem to get my comment box to input any data into my database. I set the database up on phpMyAdmin.
I can’t understand what isn’t functioning correctly as all the code im sure is correct.
Any help somone has would be greatly appreciated.
[php]<?php
mysql_connect(“localhost”,“root”,“root”);
mysql_select_db(“commentbox”);
$name=$_POST[‘name’];
$comment=$_POST[‘comment’];
$submit=$_POST[‘submit’];
$dbLink = mysql_connect(“localhost”, “root”, “root”);
mysql_query(“SET character_set_client=utf8”, $dbLink);
mysql_query(“SET character_set_connection=utf8”, $dbLink);
if($submit)
{
if($name&&$comment)
{
$insert=mysql_query("INSERT INTO commenttable (name,comment) VALUES (’$name’,’$comment’) ");
}
else
{
echo “Please fill out all fields.”;
}
}
?>
Name: |
Comment: |
' . '
' . $comment . '
' . '
' . '
' ;} ?> [/php]