I’m trying to implement a comment.php script that takes the data from a html textfield and save it to a database in phpMyAdmin. Now the comment.php, which is simpler is not adding anything to a comments table.
Here’s the code for comment.php:
<?php
session_start();
require('connect.php');
$id = $_SESSION['id'];
$comment = $_POST['comment'];
$sql = "INSERT INTO `comp595ose`.`comments`
(`id`, `comment`)
VALUES
(NULL, \'This is not working\');";
$add_comment = mysql_query($sql);
echo $comment." ";
echo $id;
?>
The comments table in phpMyAdmin has only two field, id(autoincrement) and comment.
You don’t need to escape the single quotes.
Try that.. (untested)