Jump to content


This topic is now archived and is closed to further replies.


help my now freak!

Recommended Posts

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}

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
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/');


Share this post

Link to post
Share on other sites


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.