Jump to content


Photo

PHP with flash?


  • Please log in to reply
12 replies to this topic

#1 Pi_Mastuh

Pi_Mastuh
  • Members
  • PipPipPip
  • Advanced Member
  • 233 posts
  • LocationMN

Posted 12 September 2006 - 11:34 PM

I'm making a flash game where the user sends their score and it inserts it into the database but for some reason it's not connecting properly. The actionscript for the send score button instance is:

on(press) {
	getURL("maze1.php", "score");
}

Maze 1 is:

<?
	  if ($msg == 1) {
	  print"<BR><BR><P align=center><font face='Arial, Helvetica, sans-serif' size=2>You have earned $mds Points.</font></P>
	  <P align=center><font face='Arial, Helvetica, sans-serif' size=2><a href=games.php>Play Again</a></font></P>";
	    
	  }
	  
	  if ($error == 2) {
	  print"<BR><BR><P align=center><font face='Arial, Helvetica, sans-serif' size=2>Sorry, your score does not count as you have already submitted it more then the 7 times. You can play as many times as you want but you can only submit your score 7 times.</font></P>
	  <P align=center><font face='Arial, Helvetica, sans-serif' size=2><a href=games.php>Play Again</a></font></P>";
	    
	  }
	  
	  ?>

Schroedinger's Cat walks into a bar.
And doesn't.

#2 mainewoods

mainewoods
  • Members
  • PipPipPip
  • Advanced Member
  • 685 posts
  • LocationMaine

Posted 13 September 2006 - 12:45 AM

halfway down this page:
http://livedocs.macr...e=00001730.html

#3 Pi_Mastuh

Pi_Mastuh
  • Members
  • PipPipPip
  • Advanced Member
  • 233 posts
  • LocationMN

Posted 15 September 2006 - 12:27 AM

I can't get it to send the variable and recieve it in the php file. How do I send a variable?
Schroedinger's Cat walks into a bar.
And doesn't.

#4 Wintergreen

Wintergreen
  • Members
  • PipPipPip
  • Advanced Member
  • 107 posts

Posted 15 September 2006 - 12:32 AM

If you're sending a variable to a php page:

page.php?variable_name=value

And in page.php, you access the variable with

$_GET['variable_name']

#5 Pi_Mastuh

Pi_Mastuh
  • Members
  • PipPipPip
  • Advanced Member
  • 233 posts
  • LocationMN

Posted 15 September 2006 - 12:37 AM

Where do I put that (the actionscript part) and what woul the value be because I'm trying to send the score and it varries game to game.
Schroedinger's Cat walks into a bar.
And doesn't.

#6 Wintergreen

Wintergreen
  • Members
  • PipPipPip
  • Advanced Member
  • 107 posts

Posted 15 September 2006 - 12:48 AM

admitedly I've never dealt with actionscript.  But I'm assuming you know how to get from one page to the other, and you can pass the variable in the value area.  So with PHP variables looking like $value, the link would look like  page.php?score=$value

#7 Pi_Mastuh

Pi_Mastuh
  • Members
  • PipPipPip
  • Advanced Member
  • 233 posts
  • LocationMN

Posted 15 September 2006 - 12:50 AM

That doesn't work. It doesn't like the $.
Schroedinger's Cat walks into a bar.
And doesn't.

#8 markbett

markbett
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts

Posted 15 September 2006 - 08:11 AM

lol dont put in the $ put the actual value you want but you shouldnt use a GET you should use a POST otherwise people will change their scores

#9 mainewoods

mainewoods
  • Members
  • PipPipPip
  • Advanced Member
  • 685 posts
  • LocationMaine

Posted 15 September 2006 - 04:26 PM

This should work:
on(press) {
    getURL("maze1.php?score=<?php echo $score; ?>");
}
-you would have to had set the $score php variable somewhere above in php code


#10 Pi_Mastuh

Pi_Mastuh
  • Members
  • PipPipPip
  • Advanced Member
  • 233 posts
  • LocationMN

Posted 15 September 2006 - 08:42 PM

How do I set the score variable? (I'm really new at this  :-\)
Schroedinger's Cat walks into a bar.
And doesn't.

#11 mainewoods

mainewoods
  • Members
  • PipPipPip
  • Advanced Member
  • 685 posts
  • LocationMaine

Posted 16 September 2006 - 01:04 AM

is the page that action script is running in a php page?  otherwise you are on the wrong message board.

#12 Pi_Mastuh

Pi_Mastuh
  • Members
  • PipPipPip
  • Advanced Member
  • 233 posts
  • LocationMN

Posted 16 September 2006 - 01:08 AM

No, I'm trying to send data from the flash game TO the PHP page.
Schroedinger's Cat walks into a bar.
And doesn't.

#13 Wintergreen

Wintergreen
  • Members
  • PipPipPip
  • Advanced Member
  • 107 posts

Posted 16 September 2006 - 01:27 AM

Well, I assume that Flash has variables?  $blah denotes a PHP variable.  Flash isn't PHP, so using the $ wouldn't work.  Again, I don't know actionscript but there has to be a way to send the score with a link like blah.php?score=variable.

Getting the variable once you've sent it is easy.  So you probably need to find someone who can do Flash




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users