0

I am very flattered and I would say W3Schools is a great place to learn but also I have posted a few video tutroials on youtube under the username W3Hut so you could check them out.

Okay so lets get back to having an include file as appose to the code blocks. Create a file name global.inc, this will hold the functions needed.

In this file add the following lines of code:

<?php
        
            function sql_con() {
                $con = mysql_connect( "HOST" , "USERNAME" , "PASSWORD" );
                $db = mysql_select_db( "DATABASE_NAME" , $con );   
            }
            
            function returnDls( $file ) {
                sql_con();
                $q = mysql_query("SELECT * FROM counter WHERE file='$file'");
                $array = mysql_fetch_array( $q );
                echo $array['dls'];
            }
        
        ?>

This file will be done and all you have to do is save it.

Now we can remove that block of code from any page that has it on including counter.php. Please make sure not to remove the sql_con(); on its own as this connects to the database.

At the top of any document that may use the functions (count.php, download page) add this one and only line @include("PATH TO GLOBAL.INC"); Please make sure also that the path to the file is the one you would use if it were on your local machine not as if it were a website.

For example on my shared server I would use @include("/home/username/public_html/global.inc"); this would then add the functions in just that line. If I was to link it on my local server it would be @include("C:/xampp/htdocs/global.inc"); for more info on your root directory contact your host.

You shouldn't need to edit anything more. The only thing you need to do is edit the global.inc document with you mysql details that are in the sql_con() function.

I will remake the documents so as you can understand a little better. I always find looking at the code makes more sense than the developer telling you what is going on :D.

0

I am very flattered and I would say W3Schools is a great place to learn but also I have posted a few video tutroials on youtube under the username W3Hut so you could check them out.

Okay so lets get back to having an include file as appose to the code blocks. Create a file name global.inc, this will hold the functions needed.

In this file add the following lines of code:

<?php
        
            function sql_con() {
                $con = mysql_connect( "HOST" , "USERNAME" , "PASSWORD" );
                $db = mysql_select_db( "DATABASE_NAME" , $con );   
            }
            
            function returnDls( $file ) {
                sql_con();
                $q = mysql_query("SELECT * FROM counter WHERE file='$file'");
                $array = mysql_fetch_array( $q );
                echo $array['dls'];
            }
        
        ?>

This file will be done and all you have to do is save it.

Now we can remove that block of code from any page that has it on including counter.php. Please make sure not to remove the sql_con(); on its own as this connects to the database.

At the top of any document that may use the functions (count.php, download page) add this one and only line @include("PATH TO GLOBAL.INC"); Please make sure also that the path to the file is the one you would use if it were on your local machine not as if it were a website.

For example on my shared server I would use @include("/home/username/public_html/global.inc"); this would then add the functions in just that line. If I was to link it on my local server it would be @include("C:/xampp/htdocs/global.inc"); for more info on your root directory contact your host.

You shouldn't need to edit anything more. The only thing you need to do is edit the global.inc document with you mysql details that are in the sql_con() function.

I will remake the documents so as you can understand a little better. I always find looking at the code makes more sense than the developer telling you what is going on :D.

Thanks for replying. Yes if you could remake the documents and i will then fully understand. That what i meant all along, i am sorry for not explaining myself properly.

Thank you,
genieuk

0

Well i am impressed. Thank you so much!

Will test very soon and let you know how it went.

Thank you so much for alll your help, kindess and patience.

Regards
genieuk

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.