Simple PHP, MySQL and ActionScript 3.0 Integration

Posted on 2009-04-23
Last Modified: 2013-11-11
Dear Master Experts,

I have problem to integrate AS3, PHP and MySQL the code doesn't work
please check my code bellow , i really need your advice and suggestion.
I made this code it's very simple what i want is i just want to insert data to MySQL database

Thanks and regards.
// --------------- AS Script File ---------- //

var myname:String = "Panda";

function sendData():Boolean


  	var request:URLRequest = new   URLRequest("http://localhost/test/urlvariable/add.php");

	var variables:URLVariables = new URLVariables();

	variables.giveName = myname; = variables;

	request.method = URLRequestMethod.POST;


	var loader:URLLoader = new URLLoader();

	loader.dataFormat = URLLoaderDataFormat.VARIABLES;


	return true;



function doStopSymbol(event:MouseEvent)





//------------------ add.php (file) ------------------- //


	$posted = $_POST['giveName'];


	// Connection DB

		$link = mysql_connect(locahost, root, password, dbname );

		if (!$link) {

			die('Connection Impossible: ' . mysql_error());



			$sql = "INSERT INTO contactname (id, name) VALUES ('', '$posted')";


			echo "answer=$posted";



		// Disconnect DB


//	}


//------------------ SQL ------------------- //

CREATE TABLE contactname(

  ID int(5) NOT NULL auto_increment,

  name text NOT NULL,



Open in new window

Question by:beyoursound
    LVL 8

    Accepted Solution


    32: $link = mysql_connect(locahost, root, password, dbname );
    Shouldn't this be...
    $link = mysql_connect(locahost, root, password);
    The 4th parameter is a BOOL that determines if it a new link or not.

    Open in new window

    LVL 8

    Expert Comment

    Just curious as to why you gave me a B. If I can understand why, it will help me in the future when dealing with other questions.

    I am glad my solution solved your problem nonetheless.


    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
    Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit ( and similar technologies have enjoyed wide adoption, making it possib…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
    The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now