carl_laruso Posted November 5, 2009 Share Posted November 5, 2009 Hey guys i'm trying to get 2 variables out of a flash game into a mysql dB via PHP var1 an email var2 a score the problem is my flash movie keeps saying "undefined" and the variables are not passed to the MySQL data base fire fox tamper says that POST_DATA is chucking out a score as var2 and a email as var1 my PHP code is below (i've blanked out the user/password stuff) <? $mysqlhost = "*********"; $mysqluser = "*********"; $mysqlpass = "*********"; $mysqldatabase = "*********"; mysql_pconnect($mysqlhost, $mysqluser, $mysqlpass); mysql_select_db($mysqldatabase); $name = strip_tags($_REQUEST["var1"]); $score = strip_tags($_REQUEST["var2"]); $query = "INSERT INTO scores_ast VALUES ('$name','$score')"; mysql_query($query); ?> can anyone see anything wrong with it or does any one have any ideas as to why its not working? C. Quote Link to comment https://forums.phpfreaks.com/topic/180433-passing-variables-to-mysql-from-flash-via-php/ Share on other sites More sharing options...
carl_laruso Posted November 5, 2009 Author Share Posted November 5, 2009 also i should of mentioned that my MySQL looks like this..... Quote Link to comment https://forums.phpfreaks.com/topic/180433-passing-variables-to-mysql-from-flash-via-php/#findComment-951901 Share on other sites More sharing options...
carl_laruso Posted November 5, 2009 Author Share Posted November 5, 2009 bump Quote Link to comment https://forums.phpfreaks.com/topic/180433-passing-variables-to-mysql-from-flash-via-php/#findComment-952122 Share on other sites More sharing options...
carl_laruso Posted November 6, 2009 Author Share Posted November 6, 2009 one last try - i'd really appreciate any kind of pointer on this one guys its actually driving me nuts! c. Quote Link to comment https://forums.phpfreaks.com/topic/180433-passing-variables-to-mysql-from-flash-via-php/#findComment-952406 Share on other sites More sharing options...
seanlim Posted November 6, 2009 Share Posted November 6, 2009 Is your insert statement correct? You seem to be inserting a record with 2 columns in a table which has 3 columns. Use null for id since it is an auto_increment column. And also, rmb to use mysql_real_escape_string() around your input variables. Quote Link to comment https://forums.phpfreaks.com/topic/180433-passing-variables-to-mysql-from-flash-via-php/#findComment-952409 Share on other sites More sharing options...
Joshua4550 Posted November 6, 2009 Share Posted November 6, 2009 Is your insert statement correct? You seem to be inserting a record with 2 columns in a table which has 3 columns. Use null for id since it is an auto_increment column. And also, rmb to use mysql_real_escape_string() around your input variables. Or just define which values are being inserted with the query, for example: $query = "INSERT INTO `scores_ast` (`score`, `name`) VALUES ('$name','$score')"; Quote Link to comment https://forums.phpfreaks.com/topic/180433-passing-variables-to-mysql-from-flash-via-php/#findComment-952411 Share on other sites More sharing options...
Thauwa Posted November 6, 2009 Share Posted November 6, 2009 Hi. What is the coding you used in flash to send the data? Quote Link to comment https://forums.phpfreaks.com/topic/180433-passing-variables-to-mysql-from-flash-via-php/#findComment-952412 Share on other sites More sharing options...
carl_laruso Posted November 6, 2009 Author Share Posted November 6, 2009 hey guys thank you so much for your help....... just about to try a new insert statement here is my flash code - there is a lot of it but i think this is the most relevant ______________________________________________________________________ screen_gameover.dyn_feedback.text = ""; // Clear the reporting field. datatarget = "**************************************************"; // this is correct function collectdata():Void{ capsname = screen_gameover.theinput.text.charAt(0).toUpperCase()+screen_gameover.theinput.text.slice(1); // Force a capital on the gramatically lazy user gamedata = new LoadVars(); gamedata.var1 = capsname; gamedata.var2 = _root.score; trace (gamedata); trace ("=============================="); } screen_gameover.btn_submit.onRelease = function(){ if (screen_gameover.theinput.text == "" || screen_gameover.theinput.text == initmsg){ screen_gameover.dyn_feedback.text = "Please Enter Your E-Mail"; // Tell user cleartimer = setInterval(clearmsg, 2500); // So message above disappears after 4 seconds } else { // Only send if there is some text screen_gameover.btn_submit._visible = false; screen_gameover.btn_restart._visible = true; // now alow the user to restart the game collectdata(); gamedata.sendAndLoad(datatarget,gamedata,"post"); gamedata.onLoad = function(ok) { if (ok) { screen_gameover.dyn_feedback.text = this.msg; Key.removeListener(keyListener); } else { screen_gameover.dyn_feedback.text = "There was an error sending the data!"; screen_gameover.btn_submit._visible = true; } } _root.clearfield(); // Remove all badies again, just to be sure. } } Quote Link to comment https://forums.phpfreaks.com/topic/180433-passing-variables-to-mysql-from-flash-via-php/#findComment-952425 Share on other sites More sharing options...
carl_laruso Posted November 6, 2009 Author Share Posted November 6, 2009 ok i tried Joshua4550's insert statement but the flash game is still reporting "undefined" the PHP now looks like this: <? $mysqlhost = "**********"; $mysqluser = "**********"; $mysqlpass = "**********"; $mysqldatabase = "**********"; mysql_pconnect($mysqlhost, $mysqluser, $mysqlpass); mysql_select_db($mysqldatabase); $name = strip_tags($_REQUEST["var1"]); $score = strip_tags($_REQUEST["var2"]); $query = "INSERT INTO `scores_ast` (`score`, `name`) VALUES ('$name','$score')"; mysql_query($query); ?> DOH!!! also FYI i am copying and pasting the DB name and user etc directly just out of interest where is the word "undefined" coming from? Quote Link to comment https://forums.phpfreaks.com/topic/180433-passing-variables-to-mysql-from-flash-via-php/#findComment-952430 Share on other sites More sharing options...
carl_laruso Posted November 7, 2009 Author Share Posted November 7, 2009 is there any more information i could give you guys to help out? C. Quote Link to comment https://forums.phpfreaks.com/topic/180433-passing-variables-to-mysql-from-flash-via-php/#findComment-953053 Share on other sites More sharing options...
Thauwa Posted November 8, 2009 Share Posted November 8, 2009 Well, just out of curiosity, why do you use $_REQUEST? Quote Link to comment https://forums.phpfreaks.com/topic/180433-passing-variables-to-mysql-from-flash-via-php/#findComment-953570 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.