Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Flash to run a .php

Status
Not open for further replies.

ManicMax

Programmer
Jul 21, 2006
9
GB
What I want to have is whenever the flash screen is clicked a .php is run maybe called clicks.php. What this file will do is add 1 to a value in a mysql database, in escense logging how many clicks a user makes.
Also would it be possible to not make it run that .php when a user clicks on a normal link ??

Any help will be appriciated!
 
to get started make an invisible button the size of the stage
with instanse name clickButton
add to frame actions

clickButton.onRelease = function() {
clicked = new LoadVars();
clicked.num = 1;
clicked.ran = random(20000);
clicked.sendAndLoad("clicked.php", clicked, "POST");
delete clicked;
//the above line may not be needed
};
 
Thanks for the fast reply but im getting this error message:

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 1: Statement must appear within on handler
clickButton.onRelease = function() {

Total ActionScript Errors: 1 Reported Errors: 1
 
the code is in the wrong place

must be on the frame and not on or within the buton
 
ok ive got the code to work now but how will it work ??
I mean what file will it be looking for where and will it run every time the background is clicked??
 
its looking for a php file in the same folder as the flash movie

if its a different location then add the path
 
ok ive got the files in the correct places but when its found the php what will it do then ?? i need to run the php next !
 
the flash file send the values to the php script which (writen correctly) will update the mysql database

 
ok and how should it be written because i cant get anything to work
 
OK here is the current problem im using this code in flash

clickButton.onRelease = function() {
clicked = new LoadVars();
clicked.num = 1;
clicked.ran = random(20000);
clicked.sendAndLoad(" clicked, "_POST");
delete clicked;
//the above line may not be needed
};

and the php file is

<?php
print "<p align='center'>";

$username = "BLAH";
$password = "BLAH";
$hostname = "BLAH";
$dbh = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
print "Connected to MySQL<br>";


$selected = mysql_select_db("test_table",$dbh)
or die("Could not select test_table");
print 'Selected "test_table" database<br>';




$result = mysql_query('SELECT id FROM stuff');
if (!$result) {
die('Invalid query: ' . mysql_error());
}
else{print 'Queried table "stuff"<br>';}

$row = mysql_fetch_array($result);

$new = "$row[id] + 1";

$result = mysql_query("UPDATE stuff SET id = $new");
if (!$result) {
die('Invalid query: ' . mysql_error());
}
else{print 'Queried table "stuff"<br>';}


print "$row[id]";

print " </p> ";


?>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top