i just found basic tutorial for myself to learn i still have trouble of how to create that insert data into the database along with images files path. Please take look at the code and see the line where it said "$pic=($_FILES['photo']['name'])";" that for inserting images file path name, is this correct code where to put for insert images file path name! if not , how can i correct, of what code to write! [syntax=php]<?php //connect to database. Username and password need to be changed mysql_connect("localhost", "root", ""); //Select database, database_name needs to be changed mysql_select_db("events"); $target = "images/"; $target = $target . basename( $_FILES['photo']['name']); $sql="INSERT INTO movie (title, state, location, date, trailer, photo) VALUES ('$_POST[title]','$_POST[state]','$_POST[location]', '$_POST[ldate]','$_POST[trailer]',$pic=($_FILES['photo']['name'])"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con) ?> [/syntax]
use concatinate $sql="INSERT INTO movie (title, state, location, date, trailer, photo) VALUES ('$_POST[title]','$_POST[state]','$_POST[location]', '$_POST[ldate]','$_POST[trailer]','".$_FILES['photo']['name']."'";
If you want to insert image path saved on your server then try using this : <?php //connect to database. Username and password need to be changed mysql_connect("localhost", "root", ""); //Select database, database_name needs to be changed mysql_select_db("events"); $target = "images/"; $target = $target . basename( $_FILES['photo']['name']); $sql="INSERT INTO movie (title, state, location, date, trailer, photo) VALUES ('$_POST[title]','$_POST[state]','$_POST[location]', '$_POST[ldate]','$_POST[trailer]','$target')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con) ?>