Jump to content

josephbupe

Members
  • Content Count

    56
  • Joined

  • Last visited

Community Reputation

0 Neutral

About josephbupe

  • Rank
    Regular Member

Profile Information

  • Gender
    Not Telling
  • Location
    Lusaka, Zambia
  1. Ok, I got it working after some modifications: if(isset($_POST['upload'])){ $familyname = trim($_POST['familyname']); $firstname = trim($_POST['firstname']); $othernames = trim($_POST['othernames']); $dateofbirth = trim($_POST['$dateofbirth']); $img = trim($_POST['imgurl']); $path=$path.$_FILES['file_upload']['name']; if(move_uploaded_file($_FILES['file_upload']['tmp_name'],$path)) { echo " ".basename($_FILES['file_upload']['name'])." has been uploaded<br/>"; echo '<img src="gallery/'.$_FILES['file_upload']['name'].'" width="80" height="100"/>'; $img=$_FILES['file_upload']['name']; $query="insert into imgtables (familyname,firstname,othernames,dateofbirth,imgurl,date) values('$familyname','$firstname','$othernames',STR_TO_DATE('$dateofbirth','%d-%m-%y'),'$img',now())"; echo($familyname); if($sp->query($query)){ echo "<br/>Inserted to DB also"; }else{ echo "Error <br/>".$sp->error; } } else { echo "There is an error,please retry or ckeck path"; } } I am trying to convert to prepared statement. Regards. Joseph
  2. Hi, The following code was written by someone else. It allows me to upload images to a directory while saving image name in the mysql table. I also want the code to allow me save other data (surname, first name) along with the image name into the table, but my try is not working, only the images get uploaded. What am I missing here? if(isset($_POST['upload'])) { $path=$path.$_FILES['file_upload']['name']; if(move_uploaded_file($_FILES['file_upload']['tmp_name'],$path)) { echo " ".basename($_FILES['file_upload']['name'])." has been uploaded<br/>"; echo '<img src="gallery/'.$_FILES['file_upload']['name'].'" width="48" height="48"/>'; $img=$_FILES['file_upload']['name']; $query="insert into imgtables (fname,imgurl,date) values('$fname',STR_TO_DATE('$dateofbirth','%d-%m-%y'),'$img',now())"; if($sp->query($query)){ echo "<br/>Inserted to DB also"; }else{ echo "Error <br/>".$sp->error; } } else { echo "There is an error,please retry or check path"; } } ?> joseph
  3. Hi, I appreciate this post. My request is if someone can kindly update the code for MySQLi and maybe provide a full working code for someone like myself. Regards. Joseph
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.