That's not a full local path, that's part of a URL.

A full path would look something like /home/myUsername/public_html/upload/ (just an example - it varies widely from server to server). Check out $_SERVER['DOCUMENT_ROOT'] to get the "full path" to the root of your website.

    bradgrafelman

    cant get you man
    please write in detail what do i do???

      Well you have two options:

      1. Find out what your local path is and hardcode it into the script. You could make a simple .php script that does this:
        <?php echo $_SERVER['DOCUMENT_ROOT'] ?>
        This will show you the full local path on the server to the root of your website. You can then use this in your script we've been discussing in this thread.

      OR:

      1. Use the $SERVER['DOCUMENT_ROOT'] variable in your script so that it dynamically inserts the correct local path to the root of your website, e.g.
        $path = $_SERVER['DOCUMENT_ROOT'] . '/path/to/dir'; // points to http://yoursite.com/path/to/dir
        
        Obviously, option #2 is more portable/versatile, but you might make a script that echo's out the doc. root just for your own curiosity so you can actually see what I'm talking about by a full local path on the server itself (as opposed to a URL, such as http://mysite.com/path/to/dir).

        then
        /www/upload
        is the folder you need.

          djjjozsi

          i did the same
          now the error came is Unable to open /www/upload/

            thax for the video

            now its working fine dudeπŸ™‚

            thax a lot once again

            meddy

              hey djjjozsi

              need one more thing a php page to upload images(in all type) in sql database or a page which contain images retrieve from sql database in different category like a,b,c,d,c and so on......

              is there any way to do thisπŸ†’πŸ˜ƒ

                Hy!

                In one hand,
                I think, you might need to open a new Thread to this πŸ™‚ If a user in the future search on the internet
                "problem in php sql querry" not to see this image uploader issue.

                In second hand, if i send you this script, you won't learn from it. Now you know how to make an uploader, on a new Thread you will get good tips how to store these filenames , users and categories in a database.

                Lets see this page, you can learn a lot from this site:
                http://www.tizag.com/beginnerT/

                Good luck πŸ™‚

                jjozsi

                  THAX

                  i am new in php and my sql can u tel me some ebooks to learn this

                  thax a lot
                  meddy

                    hi

                    the code is have posted in previous to create a link that will redirect a long link into short
                    the code is for that page is

                    <?php

                    if(empty($_GET['id']))
                    die("No data");
                    
                    $id = (int)$_GET['id'];  

                    //you're waiting just a number/integer, use the (int) cast to convert the data into integer

                    $db_name = "yourdatabasename";  //you have to change this into your database name
                    $table_name = "redirects";   // this is the table, where you store the url's
                    
                    $cnx = mysql_connect("localhost", "yourdatabasename", "yourpassword")   //this is the connection to the database
                    or die("Couldn't connect. ".mysql_error());
                    
                    $db = mysql_select_db($db_name, $cnx)
                    or die("Couldn't select database. ".mysql_error());
                    
                    $sql = "SELECT id, address FROM $table_name

                    WHERE id =".$id;

                    $result = mysql_query($sql) or die("Couldn't execute query.".mysql_error());
                    
                    if(mysql_num_rows($result)==1) //if you have a result
                    {
                        //    if you're waiting one result, don't need to use a while
                        $row = mysql_fetch_assoc($result);  //assoc gives you the field's name in an array
                        //$id = $row["id"];  //this is not necessary if you don't use that
                        $address = $row["address"];
                    }
                    header("location: $address");

                    ?>

                    and sql querry is

                    CREATE TABLE redirects ( id mediumint(8) unsigned NOT NULL auto_increment, address varchar(200) NOT NULL, label varchar(60) NOT NULL, PRIMARY KEY (id), KEY id (id, address), UNIQUE id_2 (id));

                    now my problem is that
                    i have to update the table through sql querry in phpadmin
                    i want to update this table from a page where i enter the LINK and click on button that will automatically insert the link and creat a php link
                    i need a index.php page for this...

                    i have a site that look like this check it here

                    can anyone help me to do dis

                      hello,

                      here is a basic code:
                      http://phptool.extra.hu/tutorials/how_to_make_link_base/admin.rar

                      use redirects_add.php to log in/add new urls, and inside the code see the label(username)/address(password).
                      And yes, the log in part is the same where you fill the new url πŸ™‚

                      After logged in, you can use
                      redirects_add.php to insert new record,
                      and redirects_index.php will list the url's from the table, the newest takes first. As you will see, it generates php url echo to that entry using its ID and label.

                      You did'n need to change the database table, but change in redirects_index.php file the

                      $url="http://www.mysite.com/show.php?id";

                      line.

                      And set connect.php to your mysql connection.

                      And here is how its made, the row version(without a sound):
                      (the password check and php url echo parts are missing from it)
                      http://phptool.extra.hu/tutorials/how_to_make_link_base/how_to_make_link_base.html

                      Hi,
                      jjozsi

                        i have attach a script here

                        please check this and tel me its too
                        not working any suggestion

                        when i am going to run this script in my server
                        index.php

                        the eror promt are

                        Notice: Undefined index: shorten_submitted in /www/obxhost.net/m/y/h/myhotspot/htdocs/index.php on line 25

                        Notice: Undefined variable: show in /www/obxhost.net/m/y/h/myhotspot/htdocs/index.php on line 51

                        Notice: Undefined variable: show in /www/obxhost.net/m/y/h/myhotspot/htdocs/index.php on line 56

                        Notice: Undefined variable: show in /www/obxhost.net/m/y/h/myhotspot/htdocs/index.php on line 59

                        Notice: Undefined index: destination in /www/obxhost.net/m/y/h/myhotspot/htdocs/HtmlTemplate.class.php on line 34

                        Notice: Undefined index: result in /www/obxhost.net/m/y/h/myhotspot/htdocs/HtmlTemplate.class.php on line 34

                        but its show a text box and a button too
                        when i had enter the url it displayed the short url but when i am going to rum that url it will not worked πŸ˜•πŸ˜•

                        help me!!!!!!!!!!

                          thax for u r reply
                          but please if u got time
                          atleast take a look on that attachment

                          thax once agiain

                            i've seen this code,
                            and this tiny code hasn't got an updater or delete function,
                            and has security holes.
                            -there is no password protection in the program
                            -it hasn't got a protection from SQL injections.

                            i could help you to install it (a t. video 4 example), but i don't
                            know how to replace its errors, or implement new functions.

                            Hello,
                            jjozsi.