SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot asmictech's Avatar
    Join Date
    Oct 2004
    Location
    nigeria
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    chk my image upload code

    am trying to upload image into database mysql. but fails. though no error report yet the file isn't find in the database. can someone help me out please?


    here is my code
    <?
    $surname=$_POST["text1"];
    echo $surname;
    $othernames=$_POST["text2"];
    echo $othernames;
    $contactadd=$_POST["text3"];
    echo $contactadd;
    $age=$_POST["text4"];
    echo $age;
    $payment=$_POST["text5"];
    echo $payment;
    $paymentcond=$_POST["text6"];
    echo $paymentcond;
    $picturepath=$_FILES["file1"];
    echo $picturepath;
    $sex=$_POST["sextype"];
    echo $sex;
    $job=$_POST["job"];
    echo $job;
    $stffid=$_POST["text1x"];
    echo $stffid;
    $paymode=$_POST["paymode"];
    echo $paymode;
    $fdate1=$_POST["1date1"];
    $fdate2=$_POST["1date2"];
    $fdate3=$_POST["1date3"];
    $admitdate=$fdate3."-".$fdate1."-".$fdate2;
    echo $admitdate;

    $pixopen="fopen('".$picturepath."',\"r\")";
    $pixsize="filesize('".$picturepath."')";
    $pixread="fread('".$pixopen."','".$pixsize."')";
    $data=addslashes($pixread);
    $pix_type="filetype('".$picturepath."')";

    $dbconx=mysql_connect("localhost","root");
    mysql_select_db("pixupload",$dbconx);
    $sql="insert into staffinfo values ('"
    .$surname.
    "','"
    .$othernames.
    "','"
    .$contactadd.
    "','"
    .$picturepath.
    "',"
    .$age.
    ",'"
    .$sex.
    "','"
    .$job.
    "','"
    .$admitdate.
    "',"
    .$stffid.
    ","
    .$payment.
    ",'"
    .$paymode.
    "','"
    .$paymentcond.
    "',"
    .$data.
    ",'"
    .$pix_type.
    "',"
    .$pixsize.
    ")";
    echo $sql;
    ?>


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script language="JavaScript" src="CLOCK.JS"></script><script language="JavaScript">
    <!--hide from old browsers
    defaultStatus="Today\'s date" + ":- " + i +"-" + a +"-" + k + " [" + h + "]";
    function displayimg(){
    imgsrc=document.pixupload.file1.value;
    document.pixupload.staff.src=eval("imgsrc");
    }
    function call(){
    setInterval("displayimg()",3000);
    }
    //-->
    </script>
    here is just the main part of the file pls help out. i sent data to this file from a form.
    expecting reply soonest.
    Success is achieved and maintained by those who keep trying.

    www.ngportal.net

  2. #2
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think $surname=$_POST["text1"];

    should be done like this

    PHP Code:
     
    $surname 
    $_POST['text1']; 
    Im not 100% sure but I've never used "" quotes to do it.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •