Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-18-2012, 10:54 PM   PM User | #1
Ax3l
New Coder

 
Join Date: Aug 2012
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Ax3l is an unknown quantity at this point
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..
Ax3l is offline   Reply With Quote
Reply

Bookmarks

Tags
insert, mysql, pdo, php

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:52 PM.


Advertisement
Log in to turn off these ads.