CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   MySQL (http://www.codingforums.com/forumdisplay.php?f=7)
-   -   Resolved How can I store this php variable. (http://www.codingforums.com/showthread.php?t=284375)

Ax3l 12-18-2012 10:54 PM

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
                ));
       
        }
?>



All times are GMT +1. The time now is 05:53 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.