Copy link to clipboard
Copied
pls help me to code as3 to submit my variable to phpmyadmin database, it's suitable for which player can write a feedback to publisher.... pls help
Copy link to clipboard
Copied
Have you started the code to share so we can look at it?
Copy link to clipboard
Copied
not yet
Copy link to clipboard
Copied
use the filereference class to send and receive variables
Copy link to clipboard
Copied
Hi,
I assume you want to save a variable value from Adobe ActionScript 3 (AS3) into a database, probably MySQL or MariaDB.
1. Use the URLRequest class in AS3 to send the data to a PHP script on your server.
Sample code to send data:
var request:URLRequest = new URLRequest("http://your-server.com/your-script.php");
var variables:URLVariables = new URLVariables();
variables.data = yourData;
request.data = variables;
request.method = URLRequestMethod.POST;
var loader:URLLoader = new URLLoader();
loader.load(request);
2. On the server, create a PHP script to receive the data sent from AS3
and insert it into the database using PHP methods to deal with MySQL.
Sample PHP code:
<?php
// Get data from AS3
$data = isset($_POST['data']) ? $_POST['data'] : null;
if ($data === null) {
die("No data received");
}
// Connect to the database
$servername = "localhost";
$username = "yourUsername";
$password = "yourPassword";
$dbname = "yourDatabase";
$conn = new mysqli($servername, $username, $password, $dbname);
// Check the connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Prepare and execute the SQL query to insert the data
$sql = "INSERT INTO yourTable (column_name) VALUES ('$data')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
Make sure you have the correct database and server access rights configured.