I have a form that is supposed to allow the user to upload an image that will have it's file saved into the folder unitimages
and it's filename
saved into my MSSQL table column photo
in the table used_trailers1
. So far, when I hit submit on my form, with the image 4010737399_df630e8a3a_o.jpg
in the photo input. I get sent to the add.php page and the following errors are displayed:
Warning: mssql_query() [function.mssql-query]: message: Incorrect syntax near '`'. (severity 15) in D:\Hosting\a90\html\sales\add.php on line 25
Warning: mssql_query() [function.mssql-query]: Query failed in D:\Hosting\4a\html\sales\add.php on line 25
Warning: move_uploaded_file(unitimages/4010737399_df630e8a3a_o.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in D:\Hosting\4a\html\sales\add.php on line 28
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'D:\Temp\php\php4D71.tmp' to 'unitimages/4010737399_df630e8a3a_o.jpg' in D:\Hosting\45a90\html\sales\add.php on line 28
Sorry, there was a problem uploading your file.
Here is my form page's code where the image is inputted:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<form enctype="multipart/form-data" action="add.php" method="POST">
Name: <input type="text" name="title"><br>
E-mail: <input type="text" name = "description"><br>
Phone: <input type="text" name = "make"><br>
Photo: <input type="file" name="photo"><br>
<input type="submit" value="Add">
</form>
</body>
</html>
Here is the full PHP page code for the add.php page:
<?php
//This is the directory where images will be saved
$target = "unitimages/";
$target = $target . basename( $_FILES['photo']['name']);
//This gets all the other information from the form
$name=$_POST['title'];
$email=$_POST['description'];
$phone=$_POST['make'];
$pic=($_FILES['photo']['name']);
// Connects to your Database
$conn = mssql_connect('garce.com','Gdr','Rg1!');
mssql_select_db('Ggler',$conn);
if(! mssql_connect )
{
die('Could not connect: ' . mssql_get_last_message());
}
//Writes the information to the database
$mmssql_query = ("INSERT INTO `used_trailers1` VALUES ('$name', '$email', '$phone', '$pic')") ;
$Test=mssql_query($mmssql_query, $conn);
//Writes the photo to the server
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
{
//Tells you if its all ok
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";
}
else {
//Gives and error if its not
echo "Sorry, there was a problem uploading your file.";
}
?>
Thank you for any help. All help is greatly appreciated.