Go Back   kirupaForum > Development > Server-Side (PHP, SQL, ASP.NET, etc.)

Reply
 
Thread Tools Display Modes
Old 10-27-2009, 05:02 AM   #1
wkt
Registered User
(+ Flash actually) What on earth is going on?

Hi there.

I am building a Flash game and I prepare to design a high score table for it. I've got a server running. Since this is my first time doing PHP and Flash together, I first designed a form so I just need to input values for different fields in order to create a record on the high score table (as seen in my attached .fla).

The table on my database has the following structure:

player_id: auto_increment (primary key)
player_name: varchar(20)
time_complete: int(4)
resources: int(4)
accuracy: int(3)
combo: int(4)
general: int(4)

Quite straight forward actually.

Next, I use the following php script to process the data when I press "submit" on my form.

PHP Code:
<?php
 
//retrieving data from Flash
 
$player $_POST['player_name'];
 
$time $_POST['time_complete'];
 
$resources $_POST['resources'];
 
$accuracy $_POST['accuracy'];
 
$combo $_POST['combo'];
 
$general $_POST['general'];
 
//end retrieving data from Flash
 //connect to database
 
$link mysql_connect("(my server name)","(my user name)","(my password)");
 if (!
$link) {
  print 
"stat=Not connected.";
 } else {
  print 
"stat=Connected.";
 }
 
//end connect to database
 //sending scores to database
 
mysql_select_db("xth_4326941_highscore",$link);
 
$q_insert "INSERT INTO score (player_name,time_complete,resources,accuracy,combo,general) VALUES ('$player','$time','$resources','$accuracy','$combo','$general')";
 
mysql_query($q_insert);
 
/*$q_check = "SELECT * FROM score";
 $q_check_result = mysql_query($q_check);
 while($row = mysql_fetch_array($q_check_result)) {
  print "stat=$row['player_name']";
 }*/
 //end sending scores to database
 //close conection
 
mysql_close($link);
 
//end close connection
?>
The connection is made successfully as displayed by the dynamic text box with the variable name "stat". The problem is that the data in the new record inserted that way became some rubbish.

player_name: <TEXTFORMAT LEADING= //****
time_complete: 0
resources: 0
accuracy: 0
combo: 0
general: 0

**** it's really like that. "<TEXTFORMAT LEADING=". And nothing else.

compared with what I have submitted:

player_name: oi
time_complete: 98
resources: 98
accuracy: 98
combo: 98
general: 98

You'll all agree that it is quite rubbish.

Anyone knows what on earth is going on? A problem with my table (created with phpmyadmin)? Or something wrong with my server? or as simple as some silly mistakes in my script?

Thanks in advance.
Attached Files
File Type: fla php_mysql_conn.fla (64.0 KB, 1 views)

Last edited by wkt; 10-27-2009 at 06:45 AM..
wkt is offline   Reply With Quote

Sponsored Links (Guests Only) - Register | Need Help?
 

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:27 PM.

SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
Creative web apps. Make your own free flash banners and photo slideshows.
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.

Flash Transition Effects

Flash Effect Tutorials

Digicrafts Components
Flash effects. Art without coding. Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com
Streamsolutions Content Delivery Networks Flipping Book - page flip flash component.
Flash-Gallery.com - Get your flash photo gallery (flash component or swf gallery Learn how to advertise on kirupa.com
 

cdn
content delivery network (cdn)

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Copyright 2010 - kirupa.com Copyright 2010 - kirupa.com