flash actionscript:
I'm using PHP to query a MySQL database. In this particular instance, it's retrieving song names and urls to load into a Media Controller. Here's the pertinent Actionscript: thisButton.onRelease = function() { dbQuery.action = 'getSong'; dbQuery.bandId = 25; dbQuery.sendAndLoad("http://localhost/mysite/dbquery2.php?ck="+new Date().getTime(), getSong); //trace(dbQuery); // traces bandId=25&action=getSong } function gotSong(theTarget:LoadVars):Void { trace(theTarget); } var dbQuery:LoadVars = new LoadVars(); var getSong:LoadVars = new LoadVars(); getSong.onLoad = gotSong; the gotSong function simply traces "true". The PHP script is attached, if it helps. <?php // include the Database classes require_once('../mysite/database.php'); // escape quotes and apostrophes if magic_quotes_gpc off foreach($_POST as $key=>$value) { if (!get_magic_quotes_gpc()) { $temp = addslashes($value); $_POST[$key] = $temp; } } if ($_POST['action'] == 'getSong') { $sql = 'SELECT * FROM songlist WHERE band_id = "'.$_POST['bandId'].'"'; echo getUserList($sql); } function getUserList($sql) { $db = new Database('localhost','siteadmin','r4799608','mysite'); $result = $db->query($sql); $numrows = $result->num_rows; $userlist = "total=$numrows"; $counter = 0; while ($row = $result->fetch_assoc()) { $userlist .= '&song_name'.$counter.'='.urlencode(stripslashes($row['song_name'])); $userlist .= '&song_path'.$counter.'='.urlencode(stripslashes($row['song_path'])); $counter++; } $db->close(); return $userlist; } ?>
Don't see what you're looking for? Try a search.
|