Can anybody please help, I am extremely new at PHP and am wanting to make a comment section for a website that its users can upload pictures and comment. This page will only be accessible to the users who log in. I have been able to code the form in html and then code the PHP to insert the info to MySQL, but the image is not being loaded to MySQL, I don’t know exactly what should be the structure of the blob for the image in MySQL. Also, the date is not loading properly in MySQL. I have the date as timestamp and update on current timestamp, null: NO, Default:Current Timestamp. Here is my code so far, if anyone can help I would appreciate it, Thanks
[php]
<?php include('config3.php'); $name=$_POST['name']; $comment=$_POST['comment']; $image=$_POST['image']; $date=$_POST['date']; $submit=$_POST['submit']; if($submit) { if($name&&$comment) { $insert=mysql_query("INSERT INTO comment1 (name,comment,image, date) VALUES ('$name','$comment', '$image', '$date') "); echo ""; } else { echo "please fill out all fields"; } } ?>Name: |
Comment: |
$getquery=mysql_query(“SELECT * FROM comment1 ORDER BY date DESC”);
while($rows=mysql_fetch_assoc($getquery))
{
$id=$rows[‘id’];
$name=$rows[‘name’];
$image = addslashes(file_get_contents($_FILE[‘image’][‘tmp_name’]));
$date=$rows[‘date’];
$comment=$rows[‘comment’];
echo $name . ‘
’ . ‘
’ . $comment . ‘
’ . ‘
’ . ‘
’
;}
?>