stuck

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Reggie

    stuck

    I get this notice.ive look at the line 44.am new to php so i need a
    bit of help.please

    Notice: Undefined variable: filename in /home/fhlinux169/c/
    clashoff.co.uk/user/htdocs/upload.php on line 44

    this is the script:

    <?php
    $host=""; // Host name
    $username=""; // Mysql username
    $password=""; // Mysql password
    $db_name=""; // Database name
    $table=""; // Table name
    $target = "upload/";
    $target = $target . basename( $_FILES['uploaded']['name']) ;
    $ok=1;

    //This is our size condition
    $upload_size = $_FILES['uploaded']['size'];
    if ($upload_size 1000000000000)
    {
    echo "Your file is too large.<br>";
    $ok=0;
    }

    //This is our limit file type condition
    $upload_type = $_FILES['uploaded']['type'];
    if ($upload_type =="text/php")
    {
    echo "No PHP files<br>";
    $ok=0;
    }

    //Here we check that $ok was not set to 0 by an error
    if ($ok==0)
    {
    Echo "Sorry your file was not uploaded";
    }

    //If everything is ok we try to upload it
    else
    {
    if(move_uploade d_file($_FILES['uploaded']['tmp_name'], $target))
    {
    echo "The file ".
    basename( $_FILES['uploaded']['name']). " has been uploaded";
    $myfilename=bas ename( $_FILES['uploaded']['name']);

    mysql_connect(" $host", "$username" , "$password" )or die("cannot
    connect");
    mysql_select_db ("$db_name") or die("cannot select DB");
    $sql="update $table set filename = '$filename' WHERE
    username='sessi on_is_registere d('username')' ";
    mysql_query($sq l);


    }
    else
    {
    echo "Sorry, there was a problem uploading your file.";
    }
    }
    ?>

    <html>
    <body>
    <a href="/user.php">Retur n to User Page</a</form>
    </body>
    </html>

  • Jerry Stuckle

    #2
    Re: stuck

    Reggie wrote:
    I get this notice.ive look at the line 44.am new to php so i need a
    bit of help.please
    >
    Notice: Undefined variable: filename in /home/fhlinux169/c/
    clashoff.co.uk/user/htdocs/upload.php on line 44
    >
    this is the script:
    >
    <snip code>

    As it should. Where did you set $filename?

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • macca

      #3
      Re: stuck

      $myfilename=bas ename( $_FILES['uploaded']['name']);


      Change this to $filename, not $myfilename



      Comment

      Working...