Im trying to create a click counter for my website, with flash, php + mysql.
The plan is to have a button with a dynamic txt field which is will show the amount of times a file has been downloaded. So i need to read and write data to my database.
i have this code on a button
PHP Code:
clickVar = 0;
myBtn.onRelease = function() {
clickVar++;
trace(clickVar);
};
*this is what i have in my php file
<?
$DBhost = "localhost"; // Database Server
$DBuser = "root"; // Database User
$DBpass = ""; // Database Pass
$DBName = "click"; // Database Name
// Connect to mySQL Server
$DBConn = mysql_connect($DBhost,$DBuser,$DBpass) or die("Error in GuestBook Application: " . mysql_error());
// Select mySQL Database
mysql_select_db($DBName, $DBConn) or die("Error in GuestBook Application: " . mysql_error());
//mysql_query("UPDATE click_count SET click_count=(click_count + 1) WHERE click_id=1");
//mysql_query("SELECT *FROM click_count WHERE click_id=1");
$connessione = @mysql_connect($DBhost,$DBuser,$DBpass);
$database = mysql_select_db($DBName,$connessione);
$select = "SELECT *FROM click_count WHERE click_id=1";
$result = mysql_query($select);
//$rows = mysql_num_rows($result);
while($list = mysql_fetch_array($result)){
$i++;
$id = $i;
$visitor_counter = strtoupper($list["click_count"]);
print("click_counter=$visitor_counter");
}
?>
Its all abit over the place, i have a database called click, with a table called click_count.
looks like this
CREATE TABLE `click_count` (
`click_id` int(5) NOT NULL default '0',
`click_count` int(10) NOT NULL default '0'
) TYPE=MyISAM;
I understand this may seem all a little jumbled up, any help would be massivly appreciated, thanks guys
mart/.