php - inserting multiple photos into mysql database -


here code, has connection database included:

session_start();  require 'config2.php'; require_once 'user.class.php';  $target = "uploads/";  $target1 = "uploads/";  $target = $target . basename( $_files['photo']['tmp_name']);  $target1 = $target1 . basename( $_files['photo1']['tmp_name']);   //this gets other information form  $login = $_session['login'];     $name=$_post['name'];  $name1 =$_post['name1']; $pic=($_files['photo']['name']);  $pic1=($_files['photo1']['name1']);   $id=$_session['id'];  // connects database  print_r($_post); print_r($_files); print_r($_session); print_r($_get);  //$op = mysql_query("select id users id = '$id' "); //writes information database  mysql_query("insert users (name, photo, name1, photo1) values ('$name', '$photo', '$name1', '$photo1') login = '$login'") ;   // mysql_query("update users set name='$name', photo = '$pic', name1 = '$name1', photo1 = '$pic1'  login = '$login' "); //writes photo server  if(move_uploaded_file($_files['photo']['tmp_name'] ,$target) ) {    //tells if ok    echo "the file ". basename( $_files['uploadedfile']['name'] ). " has been uploaded,        , information has been added directory";    echo "<a href = 'profile.php?id=$id'>back</a>";  }   if(move_uploaded_file($_files['photo1']['tmp_name'] ,$target1) ) {    //tells if ok    echo "the file ". basename( $_files['uploadedfile']['name1'] ). " has been uploaded, , information has been added directory";    echo "<a href = 'profile.php?id=$id'>back</a>";  }  else {    //gives , error if not    echo "sorry, there problem uploading file.";  }  

this code works 1 image (uploads 1 image name database field -photo), , if change insert update. how make work multiple images , insert command ?

look @ indices , names of variables. use $_files['uploadedfile']['name1'] , $_files['photo1']['tmp_name']. sure correct? post data in $_post array, files information in $_files. names of uploaded files in $_files['photo1']['name']. never have $_files['uploadedfile']['name1'] set.

also, table structure have? have 2 name fields , 2 filepath fields?

your query incorrect. if want update table row, use update ... ... query. if want add new one, use insert without where. have commented correct one.

also, use pdo , prepared statements, really. code allows sql injections.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -