Jump to content


help my now freak!

  • Please log in to reply
2 replies to this topic

#1 corillo181

  • Members
  • PipPipPip
  • Advanced Member
  • 896 posts

Posted 07 May 2006 - 09:35 AM

come on ppl every topic i post here get like 100 view and 0 answers.. i know someone must know something i ask simple questions..

my new question is..

i got a upload script right?

so the scrib upload pics name and all that kind of pic stuff to a database right? follow along please..

now want i want to do is if that user already got a picture in there when they upload a new one to subtitude the existin data wiht the new one..

i know i can use update * from table where this and that = that..


how do i put it on a upload scrip so when the person uplload the picture it does that..

like if(userpicexist delete and update new one){ :-D}

#2 wildteen88

  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 07 May 2006 - 03:00 PM

What you will want to do is upon upload you will want chekc the database first to see if the picture file name is already in the database and if so just use the UPDATE statement or if the file doesn't exists use the INSERT statement intsead.

#3 corillo181

  • Members
  • PipPipPip
  • Advanced Member
  • 896 posts

Posted 07 May 2006 - 07:54 PM

why doesn't this one works..

include 'db.php';

$checkpic="SELECT username FROM userpic  LIMIT 1";
if($checkuser > 0){
$query00=mysql_query("UPDATE userpic WHERE username='$actuser'");
if(!query00){ echo"error";

if ($_FILES['ulfile']['type']!="image/pjpeg") {echo"that kind of file is not permitted please only use jpg images.";
if($_FILES['ulfile']['name']==""){echo"at least pic a picture man!";
$filename = $_FILES['ulfile']['name'];
$tmpname = $_FILES['ulfile']['tmp_name'];
$filesize = $_FILES['ulfile']['size'];
$filetype = $_FILES['ulfile']['type'];
$datetime = date('m-d-y h:i:s');

$filepath = $dir . $filename;
$result=copy($tmpname, $filepath);
if(!$result){ echo " a problem occur";
$sql2=mysql_query("INSERT INTO userpic (name,username,datetime, size, type, path)VALUES('$filename','$actuser','$datetime','$filesize', '$filetype', '$filepath')") or die(mysql_error());
header('Location: testphp/');

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users