I have a download page in my wapsite and each file details has enterd to a mysql database, i want to show how many times downloaded each file, its UPDATE table SET +1 Like Something arround it, But i dont know it correctly please someone help me pls
I want help in mysql please read this
Started on the old forum in June 2011 · view the original in the archive · old links redirect here
If the files table name 'files' , downloads counter column name 'downloads' and auto increment file id column name 'id' that you can use the following sql command. $id is the file id of user going to download.
UPDATE
filesSETdownloads=downloads+1 WHEREid=$id
External image (may be gone) Free Mobile Web Scripts by me: Free Youtube Downloader, Tweets Reader, Facebook Wall Posts Reader PHP Tutorials: [How to Secure Your PHP Script (PHP SECURITY)](http://coding-talk.com/f14/how-to-secure-you…
Please give me full code
Please firemax i want full code, my table name is 'example' and couner column name is 'hits' and i want update hits by my file title, not increamnt id.. Please can u give me full code.. With the sql connection
Ok, check this one
<?php
$mysqlserver = 'localhost';
$database = 'DTABASENAME';
$db_user = 'USERNAME';
$db_pass = 'PASSWORD';
$link = mysql_connect($mysqlserver, $db_user, $db_pass) or die('Could not connect to Database');
$db_id = mysql_select_db($database, $link) or die('Could not select Database');
$title = "YOUR-FILE-TITLE";
mysql_query("UPDATE `example` SET `hits`=`hits`+1 WHERE `title`=$title");
External image (may be gone) Free Mobile Web Scripts by me: Free Youtube Downloader, Tweets Reader, Facebook Wall Posts Reader PHP Tutorials: [How to Secure Your PHP Script (PHP SECURITY)](http://coding-talk.com/f14/how-to-secure-you…
Its not wrking
Its not working.. May be i dnt knw how to use it correctly.. If someone can explain more.. May be it has a column error what i have created.. Saddddddd
mysql_query("UPDATE example SET hits=hits+'1' WHERE id='$fileid'");
My Blog: http://jhommark.blogspot.com My Facebook: http://www.facebook.com/jhommark My Official Site: http://www.undergroundweb.tk My Community Site: http://undergroundwap.xtreemhost.com
This is the Code. Please help me to correct it..
<?php mysql_connect("localhost", "jayasri6_dlc", "jaya") or die(mysql_error());mysql_select_db("jayasri6_dlc") or die(mysql_error()); $id = $_GET['file']; $result = mysql_query("SELECT * FROM example WHERE title='$id'") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { $chit = $row['hits']; echo "Name:"; echo $row['title']; echo " "; echo "Artist: "; echo $row['artist']; echo " "; echo "Size:"; echo $row['size']; echo " "; echo "Downloads:"; echo $row['hits']; echo ""; echo " Date:"; echo $row['date']; echo " <a href='"; echo $row['url']; echo "'>[DOWNLOAD MP3]</a> "; }; echo " Other Options: Share This: "; ?>[&t=<?php echo $_GET['file']; ?>">](http://www.facebook.com/sharer.php?u=http://dl.jayasrilanka.net/?file=<?php%20echo%20$_GET[) | [:http://dl.jayasrilanka.net/?file=<?php echo $_GET['file']; ?>">](http://twitter.com/home?status=<?php%20echo%20$_GET[)Share Url:
<input type="text" size="12" value="http://dl.jayasrilanka.net/?file=<?php echo $_GET['file']; ?>" /><?php mysql_connect("localhost", "jayasri6_dlc", "jaya") or die(mysql_error());mysql_select_db("jayasri6_dlc") or die(mysql_error()); $id = $_GET['file']; $result = mysql_query("SELECT * FROM example WHERE title='$id'") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { $chit = $row['hits']; echo "Name:"; echo $row['title']; echo " "; echo "Artist: "; echo $row['artist']; echo " "; echo "Size:"; echo $row['size']; echo " "; echo "Downloads:"; echo $row['hits']; echo ""; echo " Date:"; echo $row['date']; echo " <a href='"; echo $row['url']; echo "'>[DOWNLOAD MP3]</a> "; }; echo " Other Options: Share This: "; ?>[&t=<?php echo $_GET['file']; ?>">](http://www.facebook.com/sharer.php?u=http://dl.jayasrilanka.net/?file=<?php%20echo%20$_GET[) | [:http://dl.jayasrilanka.net/?file=<?php echo $_GET['file']; ?>">](http://twitter.com/home?status=<?php%20echo%20$_GET[)Share Url:
<input type="text" size="12" value="http://dl.jayasrilanka.net/?file=<?php echo $_GET['file']; ?>" />
change your code like this:
<?php
session_start();
mysql_connect("localhost", "jayasri6_dlc", "jaya") or die(mysql_error());mysql_select_db("jayasri6_dlc") or die(mysql_error());
$id = $_GET['file'];
$result = mysql_query("SELECT * FROM example WHERE title='$id'") or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
$chit = $row['hits'];
echo "<div style=\"text-align:left\"><small style=\"color:red;text-align:left\">Name:</small><small style=\"color:green;\">"; echo $row['title']; echo "</small><br/>";
echo "<small style=\"color:red;text-align:left\">Artist: </small><small style=\"color:green;\">"; echo $row['artist']; echo "</small><br/>";
echo "<small style=\"color:red;\">Size:</small><small style=\"color:green;\">";
echo $row['size'];
echo "</small><br />";
echo "<small style=\"color:red;\">Downloads:</small><small style=\"color:green;\">";
echo $row['hits'];
echo "</small>";
echo "<small style=\"color:red;\"><br/>Date:</small><small style=\"color:green;\">";
echo $row['date'];
echo "</small></div><div style=\"text-align=:center\"><br/><a href='";
$_SESSION['link']=$row['url'];
echo "load.php?file=$id"; echo "'>[DOWNLOAD MP3]</a><br /></div>";
};
echo "<div style=\"text-align:left;\"><br /><span style=\"color:red\">Other Options:
</span><br /><small style=\"color:green\">Share This:
</small></div>
<div style=\"text-align:center;\">"; ?><a href="http://www.facebook.com/sharer.php?u=http://dl.jayasrilanka.net/?file=<?php echo $_GET['file']; ?>&t=<?php echo $_GET['file']; ?>"><img src="http://jayasrilanka.wen.ru/images/s_fb.gif" alt="fb"/></a> | <a href="http://twitter.com/home?status=<?php echo $_GET['file']; ?>:http://dl.jayasrilanka.net/?file=<?php echo $_GET['file']; ?>"><img src="http://jayasrilanka.wen.ru/images/s_tw.gif" alt="twit"/></a><br /><div style="text-align:left;"><br /><span style="color:red">Share Url:
</span><br /><input type="text" size="12" value="http://dl.jayasrilanka.net/?file=<?php echo $_GET['file']; ?>" />
make load.php with this code
<?php
session_start();
$id = $_GET['file'];
$link=$_SESSION['link'];
mysql_connect("localhost", "jayasri6_dlc", "jaya") or die(mysql_error());mysql_select_db("jayasri6_dlc") or die(mysql_error());
$done=mysql_query("UPDATE example SET hits=hits+1 WHERE title='".$id."'");
if($done)
{
header("Location: $link");
exit();
}
?>
/* I don't know everything hehe */
Displaying Error
Its displaying error: Download ape_game_thibena.mp3Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/jayasri6/public_html/dl/index.php:2) in/home/jayasri6/public_html/dl/index.phpon line6
jayasrilanka wrote: Its displaying error: Download ape_game_thibena.mp3Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/jayasri6/public_html/dl/index.php:2) in/home/jayasri6/public_html/dl/index.phpon line6
then modify it :
<?php
mysql_connect("localhost", "jayasri6_dlc", "jaya") or die(mysql_error());mysql_select_db("jayasri6_dlc") or die(mysql_error());
$id = $_GET['file'];
$result = mysql_query("SELECT * FROM example WHERE title='$id'") or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
$chit = $row['hits'];
echo "<div style=\"text-align:left\"><small style=\"color:red;text-align:left\">Name:</small><small style=\"color:green;\">"; echo $row['title']; echo "</small><br/>";
echo "<small style=\"color:red;text-align:left\">Artist: </small><small style=\"color:green;\">"; echo $row['artist']; echo "</small><br/>";
echo "<small style=\"color:red;\">Size:</small><small style=\"color:green;\">";
echo $row['size'];
echo "</small><br />";
echo "<small style=\"color:red;\">Downloads:</small><small style=\"color:green;\">";
echo $row['hits'];
echo "</small>";
echo "<small style=\"color:red;\"><br/>Date:</small><small style=\"color:green;\">";
echo $row['date'];
echo "</small></div><div style=\"text-align=:center\"><br/><a href='";
echo "load.php?file=$id"; echo "'>[DOWNLOAD MP3]</a><br /></div>";
};
echo "<div style=\"text-align:left;\"><br /><span style=\"color:red\">Other Options:
</span><br /><small style=\"color:green\">Share This:
</small></div>
<div style=\"text-align:center;\">"; ?><a href="http://www.facebook.com/sharer.php?u=http://dl.jayasrilanka.net/?file=<?php echo $_GET['file']; ?>&t=<?php echo $_GET['file']; ?>"><img src="http://jayasrilanka.wen.ru/images/s_fb.gif" alt="fb"/></a> | <a href="http://twitter.com/home?status=<?php echo $_GET['file']; ?>:http://dl.jayasrilanka.net/?file=<?php echo $_GET['file']; ?>"><img src="http://jayasrilanka.wen.ru/images/s_tw.gif" alt="twit"/></a><br /><div style="text-align:left;"><br /><span style="color:red">Share Url:
</span><br /><input type="text" size="12" value="http://dl.jayasrilanka.net/?file=<?php echo $_GET['file']; ?>" />
load.php
<?php
mysql_connect("localhost", "jayasri6_dlc", "jaya") or die(mysql_error());mysql_select_db("jayasri6_dlc") or die(mysql_error());
$id = $_GET['file'];
$link=mysql_fetch_array(mysql_query("SELECT url FROM example WHERE title='".$id."'"));
$done=mysql_query("UPDATE example SET hits=hits+1 WHERE title='".$id."'");
if($done)
{
header("Location: $link[0]");
exit();
}
?>
/* I don't know everything hehe */
