Jump to content

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..

but

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}
Link to comment
https://forums.phpfreaks.com/topic/9230-help-my-now-freak/
Share on other sites

why doesn't this one works..
[code]

<?php
session_start();
include 'db.php';
$dir="userpic/";
$actuser=$_SESSION['username'];

if(isset($_POST['upload']))
{
$checkpic="SELECT username FROM userpic  LIMIT 1";
$query7=mysql_query($checkpic);
while($checkuser=mysql_fetch_array($query7)){
if($checkuser > 0){
$query00=mysql_query("UPDATE userpic WHERE username='$actuser'");
if(!query00){ echo"error";
}
}else{


if ($_FILES['ulfile']['type']!="image/pjpeg") {echo"that kind of file is not permitted please only use jpg images.";
exit();
}
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/');
}
}
}
?>

[/code]
Link to comment
https://forums.phpfreaks.com/topic/9230-help-my-now-freak/#findComment-34120
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.