Darkwoods Posted October 24, 2008 Share Posted October 24, 2008 how do i send thumb file name to my database here is the thumbnail creator page <?php include "../admin/inc/header.php"; if(isset($_POST['submit'])) { $new_height=100; $new_width=100; $allowed_types = array( 'image/pjpeg', 'image/gif', 'image/png', 'image/jpeg'); if(in_array($_FILES['thefile']['type'], $allowed_types)) { copy ($_FILES['thefile']['tmp_name'], $_FILES['thefile']['name']) or die ("Could not copy"); echo "Name: ".$_FILES['thefile']['name'].""; echo "Size: ".$_FILES['thefile']['size'].""; echo "Type: ".$_FILES['thefile']['type'].""; $imagefile=$_FILES['thefile']['name']; list($width, $height) = getimagesize($_FILES['thefile']['name']); $image_p = imagecreatetruecolor($new_width,$new_height); if ($_FILES['thefile']['type'] == "image/gif") { $img = @imagecreatefromgif($imagefile); imagecopyresampled($image_p, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height); $thename=$_FILES['thefile']['name']; $thenames="thumb$thename"; $location="thumbs/$thenames"; imagegif($image_p,$location, 100); } else { $img = @imagecreatefromjpeg($imagefile); imagecopyresampled($image_p, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height); $thename=$_FILES['thefile']['name']; $thenames="thumb$thename"; $location="$thenames"; imagejpeg($image_p,$location, 100); } } else { print "<br>Only Gifs and Jpegs are supported. Back to <A href='../admin/test.php'>Control Panel</a>"; } } include "../admin/inc/footer.php"; ?> i tried with this code but without any luck $name=$_POST['name']; $thefile2=$_FILES['thefile']['name']; //Writes the information to the database $result = mysql_query("INSERT INTO latest (thefile, name) VALUES ('$thefile2','$name')",$connect); Quote Link to comment Share on other sites More sharing options...
Alt_F4 Posted October 24, 2008 Share Posted October 24, 2008 try this mysql_query("INSERT INTO latest (thefile, name) VALUES ('$thefile2','$name')",$connect) or die(mysql_error()); and post the result Quote Link to comment Share on other sites More sharing options...
Darkwoods Posted October 24, 2008 Author Share Posted October 24, 2008 Duplicate entry '0' for key 1 must be something with the id? Quote Link to comment Share on other sites More sharing options...
Darkwoods Posted October 24, 2008 Author Share Posted October 24, 2008 oops forgot auto_increment Quote Link to comment Share on other sites More sharing options...
Alt_F4 Posted October 24, 2008 Share Posted October 24, 2008 that'll do it! Quote Link to comment Share on other sites More sharing options...
Darkwoods Posted October 24, 2008 Author Share Posted October 24, 2008 thank you Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.