Skip to main content
fzl_rshd
Inspiring
Sep 12, 2024 5:48 AM UTC
Question

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

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 is closed to new replies. Start a new post to keep the conversation going.

4 replies

Vladin M. Mitov
Inspiring
Sep 13, 2024 10:55 AM UTC

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.


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

use the filereference class to send and receive variables

Translate
Community Expert
Sep 12, 2024 12:36 PM UTC

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

Translate
fzl_rshd
fzl_rshdAuthor
Inspiring
Sep 13, 2024 12:48 AM UTC

not yet

Translate