title: as3, MySQL PHP connection
body: <p>am trying to connect my flash project with database. However, i want to be able to submit and retrieve data from database having 3 fields (name, score and date). My problem is that if I click submit button and when i go to check in database i only see 0 score meaning nothing is submitted. Can someone help me on this. Tq 
  Here is my coding for flash:</p>
  
  <pre><code>var str:String = "";
  var myscore = 0;
  btn_submit.addEventListener(MouseEvent.CLICK, submitted);
  
  function submitted(e:MouseEvent)
  {
  var myrequest:URLRequest = new URLRequest("http://127.0.0.1/Y/sendscore.php");
  myrequest.method = URLRequestMethod.POST;
  var variables:URLVariables = new URLVariables();
  variables.name = str;
  variables.score = myscore;
  myrequest.data = variables;
  var loader:URLLoader = new URLLoader();
  loader.dataFormat = URLLoaderDataFormat.VARIABLES;
  loader.addEventListener(Event.COMPLETE, dataOnLoad);
  loader.load(myrequest);
  }
  
  function dataOnLoad(evt:Event)
  {
  MC_success.alpha=100;
  //status is a custom flag passed from back-end 
  }
  </code></pre>
  
  <p>MY PHP CODE FOR SENDING DATA;</p>
  
  <pre><code>&lt;?php
      //Include database connection details
      require_once('config.php');
  
          //Connect to mysql server
      $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
      if(!$link) {
          die('Failed to connect to server: ' . mysql_error());
      }
  
      //Select database
      $db = mysql_select_db(DB_DATABASE);
      if(!$db) {
          die("Unable to select database");
      }
  
  //Function to sanitize values received from the form. Prevents SQL injection
      function clean($str) {
          $str = @trim($str);
          if(get_magic_quotes_gpc()) {
              $str = stripslashes($str);
          }
          return mysql_real_escape_string($str);
      }
  
      //Sanitize the POST values
      $name = clean($_POST['name']);
      $score = clean($_POST['score']);
          $currentdate = date("Y/m/d");
  
      //Create INSERT query
      $qry = "INSERT INTO highscores(user, score, date) VALUES('$name','$score','$currentdate')";
      $result = @mysql_query($qry);
  echo "writing=Ok";
  exit();
  mysql_close();  
  
  ?&gt;
  </code></pre>
  
  <p>MY PHP CODE TO RETRIEVE DATA;</p>
  
  <pre><code>&lt;?php   
      //Include database connection details
      require_once('config.php');
  
          //Connect to mysql server
      $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
      if(!$link) {
          die('Failed to connect to server: ' . mysql_error());
      }
  
      //Select database
      $db = mysql_select_db(DB_DATABASE);
      if(!$db) {
          die("Unable to select database");
      }
  
      //Create INSERT query
      $qry = "SELECT * FROM highscores ORDER BY score ASC";
      $result = @mysql_query($qry);
          $num=mysql_numrows($result);
  if($num &gt; 10)
  {$num = 10;}
  //echo "writing=Ok";
  
  echo "&lt;b&gt;&lt;center&gt;Best Times:&lt;/center&gt;&lt;/b&gt;&lt;br /&gt;&lt;table&gt;";
  
  $i=0;
  $i2=1;
  while ($i &lt; $num) {
  
  $name=mysql_result($result,$i,"user");
  $time=mysql_result($result,$i,"score");
  $date=mysql_result($result,$i,"date");
  
  
  echo "&lt;tr&gt;&lt;td align=left valign=top&gt;$i2.&lt;/td&gt;&lt;td align=center valign=top&gt;&lt;b&gt;$name&lt;/b&gt; | $score | $date&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=2&gt;&lt;hr&gt;&lt;/td&gt;&lt;/tr&gt;";
  $i2++;
  $i++;
  }
  echo "&lt;/table&gt;";
  //$urlRefresh = "scores.php";
  //header("Refresh: 15; URL=\"" . $urlRefresh . "\"");
  
  exit();
  mysql_close();
  
  
  ?&gt;
  </code></pre>