Skip to main content
fzl_rshd
Inspiring
September 12, 2024
Question

Please help me to code AS3 submit my variable to phpMyAdmin Database...🙏

  • September 12, 2024
  • 3 replies
  • 295 views

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

This topic has been closed for replies.

3 replies

Vladin M. Mitov
Inspiring
September 13, 2024

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.


- Vlad: UX and graphic design, Flash user since 1998Member of Flanimate Power Tools team - extensions for character animation
kglad
Community Expert
Community Expert
September 12, 2024

use the filereference class to send and receive variables

Community Expert
September 12, 2024

Have you started the code to share so we can look at it?

fzl_rshd
fzl_rshdAuthor
Inspiring
September 13, 2024

not yet