I need help with this code.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • basestring
    New Member
    • Mar 2007
    • 3

    I need help with this code.

    Hi, I need help for my program.

    I'm new With PHP but i have programming skills in VB so it's quit easy to understand this language, however. i got my self in some problems that i don't understand.

    I made a form that should add a record to a database and upload a picture
    to a databasepicture s folder

    the problems is it doesn't upload the selected file.
    and $_files vars are empty

    when I do a $_request first, The filename is stored like "C:\\folder\\te st.jpg"

    Please help

    This is my form it as PHP in it to get de details from my database

    <form name="form1" method="post" action="index.p hp">
    <?
    $user="myuserna me";
    $password="mypa ssword";
    $database="myda tabase";
    $pro_id=$_POST['pro_id'];
    $pro_type=$_POS T['pro_type'];
    mysql_connect(l ocalhost,$user, $password);
    @mysql_select_d b($database) or die( "Unable to select database");
    $query="SELECT * FROM pro_index";
    mysql_query($qu ery);
    $result=mysql_q uery($query);
    $num=mysql_numr ows($result);
    $i=0;
    ?>
    Product type
    <select name="type" size="1">
    <?
    while ($i < $num) {
    $pro_id=mysql_r esult($result,$ i,"pro_type_cod e");
    $pro_type=mysql _result($result ,$i,"Pro_type") ;
    echo "<option>$pro_t ype</option>";
    $i++;
    }
    mysql_close();
    ?>
    </select>
    <?
    $pro_code_our++ ;
    Echo "<br>Produc t number = BS$pro_code_our </p>";
    ?>
    <br>
    Product number from Factory
    <input type="text" name="pronum">
    <br>
    Product name
    <input type="text" name="proname">
    <br>
    Product details
    <input type="text" name="prodetail s" size="50">
    <br>
    Box size
    <input type="text" name="probox">
    <br>
    Quantity
    <input type="text" name="proquanti ty">
    <br>
    Picture
    <INPUT NAME="uploaded" TYPE="File">

    <br>
    Factory number
    <input type="text" name="facnum">
    <br>
    Buy Price
    <input type="text" name="price">
    <br>
    <input type="submit" name="Submit" value="Add record">
    <br>
    </form>

    this is my PHP code i try to use but doesn't work

    <?
    $target = "databasepictur es/";
    $target = $target . basename( $_FILES['uploaded']['name']) ;
    $ok=1;
    if(move_uploade d_file($_FILES['uploaded']['tmp_name'], $target))
    {
    echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
    }
    else {
    echo "Sorry, there was a problem uploading your file.";
    }
    ?>

    This doesn't work and if i Print the $target it shows only "databasepictur es/"
    What is wrong or waht is missing
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Welcome to TSDN!

    Please read the Posting Guidelines before you post in this forum!.

    Especially the part about enclosing shown code within code or php tags! This is absolutely unreadable.

    Also check the meaningfulness of your thread title. Everyone in this forum needs help with his/her code. So it really does not stick out.

    moderator

    Comment

    Working...