Web Analytics Made Easy -
StatCounter after upload - CodingForum

Announcement

Collapse
No announcement yet.

after upload

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • after upload

    i have a upload page: http://www.dangmn.net/tgl/upload.php

    when i try to upload a replay it goes into a blank page, and not into the page i want it to go to which is http://www.dangmn.net/tgl/display_reps.php

    i think something is wrong, missing from my syntax code like missing a simi colon or a tag, can someone take a look at it for me thanks!

    PHP Code:
    <?php

    session_start
    ();     //note session here
    //set local variables

    $dbhost "localhost"
    $dbuser "dangmnne_setname"
    $dbpass "abc123"
    $dbname "dangmnne_setname"

    //connect 
    $db mysql_connect($dbhost,$dbuser,$dbpass); 
    mysql_select_db("$dbname",$db); 

    if (!
    $db)
      {
      die(
    'Could not connect: ' mysql_error());
      }


    $db mysql_connect($dbhost,$dbuser,$dbpass);
    mysql_select_db("$dbname",$db); 

    if (!
    db_selected)
    {

    die(
    "cant connect");

    }

        if (
    $_FILES["file"]["error"] > 0)
        {
        echo 
    "Return Code: " $_FILES["file"]["error"] . "<br />";
        }
      else
        {
            
    move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" $_FILES["file"]["name"]);

            
    $replay "upload/" $_FILES["file"]["name"];
            
    $replay2 "<a href=\"http://www.dangmn.net/tgl/upload/" .$replay"\"><img src = \"http://www.dangmn.net/image.jpg\" style=\"border-style: none\"/></a>"//replace "yoursite" with your own site

            
    $query "INSERT INTO test (replay) 
    VALUES ('"
    .$replay2."')";

    $result mysql_query($query) or die(mysql_error());

    mysql_close($db);
            


    ?>

  • #2
    Try:
    PHP Code:
    <?php

    session_start
    ();     //note session here
    //set local variables

    $dbhost "localhost"
    $dbuser "dangmnne_setname"
    $dbpass "abc123"
    $dbname "dangmnne_setname"

    //connect 
    $db mysql_connect($dbhost,$dbuser,$dbpass); 
    mysql_select_db("$dbname",$db); 

    if (!
    $db)
      {
      die(
    'Could not connect: ' mysql_error());
      }


    $db mysql_connect($dbhost,$dbuser,$dbpass);
    mysql_select_db("$dbname",$db); 

    if (!
    db_selected)
    {

    die(
    "cant connect");

    }

        if (
    $_FILES["file"]["error"] > 0)
        {
        echo 
    "Return Code: " $_FILES["file"]["error"] . "<br />";
        }
      else
        {
            
    move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" $_FILES["file"]["name"]);

            
    $replay "upload/" $_FILES["file"]["name"];
            
    $replay2 "<a href=\"http://www.dangmn.net/tgl/upload/" .$replay"\"><img src = \"http://www.dangmn.net/image.jpg\" style=\"border-style: none\"/></a>"//replace "yoursite" with your own site

            
    $query "INSERT INTO test (replay) 
    VALUES ('"
    .$replay2."')";

    $result mysql_query($query) or die(mysql_error());

    mysql_close($db);
            
    header("Location: http://www.dangmn.net/tgl/display_reps.php");

    ?>

    Comment


    • #3
      thanks that works, but the file i upload still doesn't display on that page http://www.dangmn.net/tgl/display_reps.php nor is the file uploaded in my host under the "upload" folder

      do you know whats wrong or would you like to see the scripts for those 2 file.

      Comment


      • #4
        yes, please post the scripts....

        Comment


        • #5
          okay, here are the two files

          display_rep.php

          PHP Code:
          <?php

          session_start
          ();     //note session here
          //set local variables
          http://www.codingforum.net/editpost.php?do=editpost&p=802321
          $dbhost "localhost"
          $dbuser "dangmnne_setname"
          $dbpass "abc123"
          $dbname "dangmnne_setname"

          //connect 
          $db mysql_connect($dbhost,$dbuser,$dbpass); 
          mysql_select_db("$dbname",$db); 

              
          if (!
          $db)
            {
            die(
          'Could not connect: ' mysql_error());
            }


          $db mysql_connect($dbhost,$dbuser,$dbpass);mysql_select_db("$dbname",$db); 

          if (!
          db_selected)
          {

          die(
          "cant connect");

          }

          $result mysql_query("SELECT replay FROM test");

          echo 
          "<table align='center' width='30%' bgcolor='#FFFFFF' style='border-color:#000;border-style:solid; border-width:1px' border=0>
          <tr>
          <th><FONT COLOR='#000'>Replay</th>
          </tr>"
          ;


          while(
          $row mysql_fetch_array($result))
            {
            
            echo 
          "<tr>";
            echo 
          "<td ALIGN='CENTER'><FONT COLOR='#000000'>" $row['replay'] . "</td>";
            echo 
          "</tr>";
             }
            
          echo 
          "</table>";

          mysql_close($db);

          ?>

          upload.php

          PHP Code:
          <html>
          <
          body>

          <
          form action="process_upload.php" method="post">
          <
          label for="file">Replay:</label>
          <
          input type="file" name="file" id="file" /> 
          <
          br />
          <
          input type="submit" name="Upload" value="Submit" />
          </
          form>

          </
          body>
          </
          html
          Last edited by LambofGod; Apr 5, 2009, 08:02 AM.

          Comment


          • #6
            did you only need the display_rep.php correct?

            Comment


            • #7
              Can you post process_upload.php because it seems that they weren't stored in mysql....

              Comment


              • #8
                yeah no problem,

                process_upload.php
                PHP Code:
                <?php

                session_start
                ();     //note session here
                //set local variables

                $dbhost "localhost"
                $dbuser "dangmnne_setname"
                $dbpass "xxxxxx"
                $dbname "dangmnne_setname"

                //connect 
                $db mysql_connect($dbhost,$dbuser,$dbpass); 
                mysql_select_db("$dbname",$db); 

                if (!
                $db)
                  {
                  die(
                'Could not connect: ' mysql_error());
                  }


                $db mysql_connect($dbhost,$dbuser,$dbpass);
                mysql_select_db("$dbname",$db); 

                if (!
                db_selected)
                {

                die(
                "cant connect");

                }

                    if (
                $_FILES["file"]["error"] > 0)
                    {
                    echo 
                "Return Code: " $_FILES["file"]["error"] . "<br />";
                    }
                  else
                    {
                        
                move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" $_FILES["file"]["name"]);

                        
                $replay "upload/" $_FILES["file"]["name"];
                        
                $replay2 "<a href=\"http://www.dangmn.net/tgl/upload/" .$replay"\"><img src = \"http://www.dangmn.net/image.jpg\" style=\"border-style: none\"/></a>";

                        
                $query "INSERT INTO test (replay) 
                VALUES ('"
                .$replay2."')";

                $result mysql_query($query) or die(mysql_error());

                mysql_close($db);
                        
                header("Location: http://www.dangmn.net/tgl/display_reps.php");

                ?>

                Comment


                • #9
                  yea i tried everything but no luck

                  Comment


                  • #10
                    anybody?

                    Comment


                    • #11
                      Check you phpMyAdmin and see if the thing is added in....

                      Comment


                      • #12
                        I have created a database called "test" and even have a table called "replays" when i upload my replay files, i can see it in my database through myPHPADMIN but it does not upload into the folder /upload nor does it display on the display page where i want it to which is the display_rep.php can you tell me what's the problem, here I'll give you the scripts.

                        upload.php
                        http://www.dangmn.net/hp/upload.php
                        PHP Code:
                        <html>
                        <
                        body>

                        <
                        form action="process_upload.php" method="post"
                        <label for="file">Replay:</label>
                        <
                        input type="file" name="file" id="file" /> 
                        <
                        br />
                        <
                        input type="submit" name="Upload" value="Submit" />
                        </
                        form>

                        </
                        body>
                        </
                        html
                        Process_Upload.php
                        http://www.dangmn.net/hp/process_upload.php
                        PHP Code:
                        <?php

                        $db 
                        mysql_connect('localhost''dangmnne_dangmnx''password'); //fill in host, hostname, hostpass with your own

                        if (!$db)
                          {
                          die(
                        'Could not connect: ' mysql_error());
                          }


                        $db_selected mysql_select_db('dangmnne_test'$db); //fill in DBname with your own

                        if (!db_selected)
                        {

                        die(
                        "cant connect");

                        }

                            if (
                        $_FILES["file"]["error"] > 0)
                            {
                            echo 
                        "Return Code: " $_FILES["file"]["error"] . "<br />";
                            }
                          else
                            {
                                
                        move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" $_FILES["file"]["name"]);

                                
                        $replay "upload/" $_FILES["file"]["name"];
                                
                        $replay2 "<a href=\"http://www.dangmn.net/hp/upload/" .$replay"\"><img src = \"http://www.dangmn.net/image.jpg\" style=\"border-style: none\"/></a>"//replace "yoursite" with your own site

                                
                        $query "INSERT INTO test (replay)
                        VALUES ('"
                        .$replay2."')";

                        $result mysql_query($query) or die(mysql_error());

                        mysql_close($db);
                                


                        ?>

                        display_rep.php
                        http://www.dangmn.net/hp/display_reps.php
                        PHP Code:
                        <?php

                        $db 
                        mysql_connect('localhost''dangmnne_dangmnx''dn249118'); //fill in host, hostname, hostpass with your own

                        if (!$db)
                          {
                          die(
                        'Could not connect: ' mysql_error());
                          }


                        $db_selected mysql_select_db('dangmnne_test'$db); //fill in DBname with your own

                        if (!db_selected)
                        {

                        die(
                        "cant connect");

                        }

                        $result mysql_query("SELECT replay FROM test");

                        echo 
                        "<table ALIGN='center' border='1'>
                        <tr>
                        <th><FONT COLOR='#000'>Replay</th>
                        </tr>"
                        ;


                        while(
                        $row mysql_fetch_array($result))
                          {
                          
                          echo 
                        "<tr>";
                          echo 
                        "<td ALIGN='CENTER'><FONT COLOR='#000'>" $row['replay'] . "</td>";
                          echo 
                        "</tr>";
                           }
                          
                        echo 
                        "</table>";

                        mysql_close($db);

                        ?>

                        Comment

                        Working...
                        X