Hello all
Hopefully you guys can help me.
I am trying to store an image into a database along with the users name and a comment, similar to a FB comment page in some website where there is your profile image on the left and some comments on the right.
The problem is i cant seem to display the images along with the comments in the database as the user submits them (this should all happen on a single page)
<?php include("connect.php"); // post $name=$_POST['name']; $comment=$_POST['comment']; $price=$_POST['price']; $dropdown=$_POST['dropdown']; //submit $submit=$_POST['submit']; ================want to insert this code as well so when the user uploads the image and submits the image is retrieved at the bottom of the page along with the comments==================== //file properties $file = $_FILES['image'] ['tmp_name']; if (!isset($file)) echo "Select a image"; else { $image = addslashes(file_get_contents($_FILES['image'] ['tmp_name'])); $image_name = addslashes($_FILES['image'] ['name']); $image_size = getimagesize($_FILES['image']['tmp_name']); if ($image_size == FALSE) echo "That't not an image."; else { if(!$insert = mysql_query("INSERT INTO save VALUES('','$image_name','$image')")) echo "Problem uploading image"; else { $lastid = mysql_insert_id(); echo "Image uploaded.Your image:
";
}
}
}
?>
======================The above is in a separate .php file with an upload file form==================
//post
if(isset($submit)){
//if fields are filled out
if($name&&$comment&&$price&&$dropdown)
{
$insert = mysql_query(“INSERT INTO comments0 (name,comment,price,dropdown) VALUES (’$name’,’$comment’,’$price’,’$dropdown’)”) or die (“unable to insert”);
echo "<meta http-equiv='Refresh' Content='0'; url='".$_SERVER['PHP_SELF']."'>";
}
}
?>
Untitled DocumentAdvertise: | * |
Price: | * |
Meet: | City Tech (NAM) Entrance 4th Floor Library 6th Floor Lab Cafeteria Other Locations |
Image: | |
Description | |
Image: | |
<?php include('eximage.php'); ?> | |
<?php
$getquery=mysql_query("SELECT * FROM comments0 ORDER BY id DESC");
while($rows=mysql_fetch_array($getquery))
{
$id=$rows['id'];
$name=$rows['name'];
$comment=$rows['comment'];
$price=$rows['price'];
$dropdown=$rows['dropdown'];
echo $name . '
' . $price. '
' . $comment.'
' . $dropdown .'
' .'
' ; } ?>
' . $price. '
' . $comment.'
' . $dropdown .'
' .'
' ; } ?>