Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New Coder
    Join Date
    Aug 2012
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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
    		));
    	
    	}
    ?>
    Last edited by Ax3l; 12-18-2012 at 11:16 PM.


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •