How can I store this php variable.
I would like to know how I can get the variable $filePath to work correctly in this bit of code so that it will insert.
Code:
<?php
$host = "localhost";
$user = "root";
$db = "userdata";
$pass = "";
$odb = new PDO("mysql:host=" . $host . ";dbname=" . $db, $user, $pass);
$fileName = $_FILES["uploaded_file"]["name"]; // The file name
$uploadDir = 'uploads/resized_'; //upload directory
$filePath = $uploadDir . $fileName; // file path/completed directory
if(isset($_POST['Email'])) {
$Email = $_POST['Email'];
$Link = $_POST['Link'];
$Description = $_POST['Description'];
$Country = $_POST['Country'];
$State = $_POST['State'];
$Image = $filePath;
$q = "INSERT INTO test(Email, Link, Country, State, Description, Image_directory) VALUES(:Email, :Link, :Country, :State, :Description, $filePath)";
$query = $odb->prepare($q);
$results = $query->execute(array(
":Email" => $Email,
":Link" => $Link,
":Country" => $Country,
":State" => $State,
":Description" => $Description,
"$filePath" => $Image
));
}
?>
|