Jump to content


* * * - - 1 votes

[PHP] - [Simple download counter] - [Gio]


  • Please log in to reply
30 replies to this topic

#21 SERB-4-LIFE

SERB-4-LIFE

    Young Padawan

  • Members
  • Pip
  • 65 posts

Posted 26 September 2004 - 11:31 PM

ok Gio here is the problem i added the file through mysql that was easy now i get an error so have a look at my connect file if everything is good with it

<?php
                           $username = "username";
                            $password = "password";
                            $host =  "host";
                            $database = "database";

                            mysql_connect($host,$username,$password) or die("Error connecting to Database!
" . mysql_error());

                            mysql_select_db($database) or die("Cannot select database!
" . mysql_error());
?>
i canged username, pass,host,databasename for protection :blink: but i have the corect username and pass i can connect to the database and i get this error

Could not execute query : SELECT * from counter where id='1'.No Database Selected


#22 Jamie Huskisson

Jamie Huskisson

    Retired P2L Staff

  • Members
  • PipPipPipPip
  • 3,648 posts
  • Gender:Male
  • Location:Nottingham, UK

Posted 27 September 2004 - 05:02 PM

remove double spacing between the equals sign and value of $host ?

it could be that you've forgotten to end an existing database connection before you've made that one

#23 Gio

Gio

    Jedi In Training

  • Members
  • PipPip
  • 317 posts

Posted 27 September 2004 - 05:07 PM

ok Gio here is the problem i added the file through mysql that was easy now i get an error so have a look at my connect file if everything is good with it

<?php
                           $username = "username";
                            $password = "password";
                            $host =  "host";
                            $database = "database";

                            mysql_connect($host,$username,$password) or die("Error connecting to Database!
" . mysql_error());

                            mysql_select_db($database) or die("Cannot select database!
" . mysql_error());
?>
i canged username, pass,host,databasename for protection :D but i have the corect username and pass i can connect to the database and i get this error

Could not execute query : SELECT * from counter where id='1'.No Database Selected

<?php
$username = "username";
$password = "password";
$host =  "localhost";
$database = "database";

$connect = mysql_connect($host,$username,$password) or die("Error connecting to Database! " . mysql_error());
mysql_select_db($database , $connect) or die("Cannot select database! " . mysql_error());
?>

I would do it like that

#24 ludwigw

ludwigw

    P2L Jedi

  • Members
  • PipPipPip
  • 823 posts
  • Gender:Male
  • Interests:Designer at Lee ter Wal.

Posted 25 November 2004 - 03:13 PM

Um.....is that a copy and paste code? If so where does the connect.php come from?

Can this be explained a bit more since the only understanding on php i have is <? include() ?> but Im trying to learn.

So can someone please explain this a bit more? Maybe Gio you can add me :)

[email protected] = MSN
infnit123 = AIM

#25 _*JaK3rIUS_*

_*JaK3rIUS_*
  • Guests

Posted 01 February 2005 - 02:24 AM

great man. lookin' for something like this. thanks

#26 adam123

adam123

    Retired P2L Staff

  • Members
  • PipPipPipPip
  • 2,306 posts
  • Location:London, UK
  • Interests:Programming and stuff.

Posted 01 February 2005 - 02:33 PM

<?php
$username = "username";
$password = "password";
$host =  "localhost";
$database = "database";

$connect = mysql_connect($host,$username,$password) or die("Error connecting to Database! " . mysql_error());
mysql_select_db($database , $connect) or die("Cannot select database! " . mysql_error());
?>

I would do it like that



I would do it like this:
if ($dbc = @mysql_connect ('localhost', 'username', 'password'))
{
if (!@mysql_select_db ('dbname'))
{
die ('<p>Could not select the database because: <b>' . mysql_error() . '</b>.</p>');
}
}
else
{
die ('<p>Could not connect to MySQL because: <b>' . mysql_error() . '</b>.</p>');
}


#27 _*adrian_*

_*adrian_*
  • Guests

Posted 19 April 2005 - 12:45 PM

This is a great script and works well. I added two extra fields, description and image. And I changed the echo so that it should also echo the descriptiona and image.

Note, I have changed table and column names for my use but they still worked fine. I also added
$dld_description =$row["dld_description"];
$dld_image =$row["dld_image"];
to
while ($row=mysql_fetch_array($result))
{
$id = $row["id"];
$dld_file_name = $row["dld_file_name"];
$dld_file_url = $row["dld_file_url"];
$dld_count =$row["dld_count"];
in view.php. The file name shows up, the download link works and it also shows the number of downloads, but it wont display the description or image, this is my echo code:
echo "<table width=100%  border=0 cellspacing=0 cellpadding=0>
  <tr>
    <td width=155><div align=center class=body>Download ID: $id</div></td>
    <td class=bold>$dld_file_name</td>
  </tr>
  <tr>
    <td><div align=center><img src=$dld_image></div></td>
    <td class=body>$dld_description</td>
  </tr>
  <tr>
    <td><div align=center class=body><a href=includes/download.php?id=$id>Click Here To Download</a></div></td>
    <td><div align=right class=body>Number of Downloads: $dld_count</div></td>
  </tr>
</table><Br>";
How can I get it to show the description and image. Thanks.

-Adrian

#28 _*adrian_*

_*adrian_*
  • Guests

Posted 31 May 2005 - 11:25 AM

*bump* sorry, i had to, I still have this problem you know!

#29 Ruben K

Ruben K

    Cliff

  • Twodded Staff
  • PipPip
  • 438 posts

Posted 31 May 2005 - 01:22 PM

way to necropost

#30 bondy

bondy

    Young Padawan

  • Members
  • Pip
  • 1 posts

Posted 02 June 2005 - 03:34 AM

Gio

I have somethng similar, however I want a log to record when a link has been used.

At the moment the user is given a list of links he can download. Selecting one sends him to a download.php page which displays the one link to download.

On this page the user and code is logged, however the user may decide not to select the link to download therefore the log is false.

please help.

#31 madcom

madcom

    Young Padawan

  • Members
  • Pip
  • 1 posts

Posted 31 August 2005 - 04:54 AM

my header function gives an error... what can i do..
please help me




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users