benji87 Posted November 17, 2006 Share Posted November 17, 2006 Hi all im having trouble with a script ive created to upload a image to a web server and at the same time upload some data into a sql datbase including the url to the image thats been uploaded. This is basicly two seperate scripts merged into one so im not too sure if its the streamline way to do it. It doesnt seem to work though although i dont get any errors.[code]<?include 'db.php';//GET VARIABLES$title = $_POST['title'];$message = $_POST['message'];$publish = $_POST['publish'];$title = stripslashes($title);$message = stripslashes($message);$date = date("j F");//UPLOAD IMAGE$imagename = basename($_POST['image_file']['name']);//echo $imagename;if(empty($imagename))$error["imagename"] = "The name of the image was not found.";if(empty($error)){$newimage = "../../images/newsimages/" . $imagename;//echo $newimage;$result = @move_uploaded_file($_FILES['image_file']['tmp_name'], $newimage);if(empty($result))$error["result"] = "There was an error moving the uploaded file.";}//INSERT DATA INTO DATABASE$sql = mysql_query("INSERT INTO ssrfc_news (title, message, publish, image, date) VALUES('$title', '$message', '$publish', '$result', '$date')") or die (mysql_error());if(!$sql){ echo 'There has been an error while trying to submit your post.';} else { $id = mysql_insert_id();}header("Location: ../news.php");echo 'Your article has successfully been posted.';?>[/code]Any help would be great but im guessing that the problem lies around the $_post function. 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.