flash to php PARTIALLY SOLVED

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Cateyes
Forum Commoner
Posts: 63
Joined: Mon Jun 14, 2004 5:06 pm

flash to php PARTIALLY SOLVED

Post by Cateyes »

Ok what I am trying to do is send a value from a flash button to a php script that then returns the proper values from the mySQL DB, I have a test script that works on sending the values bach to flash what I need to find out how to do is how dow I send either a number value or name from a mcbutton in flash to the php script. This is so that it return the proper info on that member this way only one php script would be needed for all the members instead of multple scripts. I know its possible just a little vague on what I need to do. Can't wait till I actually get some reading material for PHP been flying blind on this but its looking good so far.
Last edited by Cateyes on Mon Jun 21, 2004 11:13 am, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the easiest way to pass information is with the url.. i.e. a url of: www.foo.com/you/page.php?id=12&bar=george
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

and then use $_GET["id"] to pull it from the url
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

oops, forgot to add that part :D, thanks Phenom.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

np :)
Cateyes
Forum Commoner
Posts: 63
Joined: Mon Jun 14, 2004 5:06 pm

Post by Cateyes »

Ok now for a really newbish question after I put this in the php script
$_GET["id"] how do I convert it so it has the value $id? trying to test script out to see if its working.
I tried using $id=$_GET["id"] and it comes out blank. I will be buying a lot of books in 10 days so if its to newbish don't worry I think I am missing something simple worked on some code I did for half a day without relizing my problem at first was I forgot to put in the echo command was ready to smash head into wall for being so stupid.
Here is the test script I am working on

Code: Select all

<?php require_once('../Connections/Covuploads.php'); ?>
<?php
$id=$_GET["id"] 
mysql_select_db($database_Covuploads, $Covuploads);
$query_rs_cateyes = "SELECT * FROM player_profiles";
$rs_cateyes = mysql_query($query_rs_cateyes, $Covuploads) or die(mysql_error());
$row_rs_cateyes = mysql_fetch_assoc($rs_cateyes);
$totalRows_rs_cateyes = mysql_num_rows($rs_cateyes);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form name="form1" method="post" action="">
<p>
  <select name="select">
    <?php
	do {  
?>
    <option value="<?php echo $row_rs_cateyes['playerid']?>"<?php if (!(strcmp($row_rs_cateyes['playerid'], $row_rs_cateyes['playerid']))) {echo "SELECTED";} ?>><?php echo $row_rs_cateyes['alias']?></option>
    <?php
} while ($row_rs_cateyes = mysql_fetch_assoc($rs_cateyes));
  $rows = mysql_num_rows($rs_cateyes);
  if($rows > 0) {
      mysql_data_seek($rs_cateyes, 0);
	  $row_rs_cateyes = mysql_fetch_assoc($rs_cateyes);
  }
?>
  </select>
  <?

$alias = $row_rs_cateyes['alias'];
$name = $row_rs_cateyes['name'];
$profile = $row_rs_cateyes['profile'];
$age = $row_rs_cateyes['age'];
$weapon = $row_rs_cateyes['weapon'];
$quote = $row_rs_cateyes['quote'];
echo "&Varalias=$alias&";
echo "&Varname=$name&";
echo "&Varprofile=$profile&";
echo "&Varage=$age&";
echo "&Varweapon=$weapon&";
echo "&Varquote=$quote&";
echo "&Varid=$id&"
?>
  <?php
mysql_free_result($rs_cateyes);
?>
</p>
</form>
Basically I want to be able to send an id number to this script tell mysql what id number is and grab what I need I have it working if I tell mySQL in advance what record I want but thats it I could make a seperate script for each member but one would be nicer.


feyd|use

Code: Select all

tags for php code.[/color]
Last edited by Cateyes on Sun Jun 20, 2004 7:12 pm, edited 1 time in total.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

ok... lets say your flash script generations a url of http://www.domain.com/page.php?id=100

then you would have in your code

Code: Select all

<?php
//as you did assign $_GET["id"] to a variable

$id = $_GET["id"];
echo "Your id is".$id;
?>
Cateyes
Forum Commoner
Posts: 63
Joined: Mon Jun 14, 2004 5:06 pm

Post by Cateyes »

OK I just tried a simple script that should of worked and it doesn't I made a little HTML seach page called searchbtname.html heres the code:

Code: Select all

<HTML>
<HEAD>
 <TITLE>Member Search</TITLE>
 </HEAD>
 
 <BODY>
 <H2>Search for member</H2>
 <BR>
 <FORM ACTION="resultbyname.php" METHOD="POST">
 Please enter the name, or part of the name, of the member you are seeking:
 <BR>
 <INPUT NAME="name" TYPE=TEXT>
 <BR>
 <INPUT TYPE=SUBMIT VALUE="search">
 </FORM>
 </BODY>
 </HTML>
The php page is called resultbyname.php all I wanted to see was if the name would transfer over and it doesn't here is the code:

Code: Select all

<?
echo $name;
?>
This is the error that it produces:
Notice: Undefined variable: name in C:\My WebSite\resultbyname.php on line 2
I am running PHP version 4.3.1 I got this little same of a video I was watching and it's copied exactly as they did it I am wondering if its a version proble also Globals are off.
SBukoski
Forum Contributor
Posts: 128
Joined: Wed May 21, 2003 10:39 pm
Location: Worcester, MA

Post by SBukoski »

Try...

Code: Select all

<?php
echo $_POST['name'];
?>
Globals are off so $name is going to return blank for you. The notice is caused by the error reporting level.
Cateyes
Forum Commoner
Posts: 63
Joined: Mon Jun 14, 2004 5:06 pm

Post by Cateyes »

Thank you that worked so would I use $_POST['name'] as a value as well?
Cateyes
Forum Commoner
Posts: 63
Joined: Mon Jun 14, 2004 5:06 pm

Post by Cateyes »

OK here is now my search code now that I know it passes from one page to the other

Code: Select all

<?php 
echo $_POST['name']; 
?> 
<HTML>
<HEAD>
 <TITLE>Meamebers Search</TITLE>
 </HEAD>
 <BODY>
 <H2>Search Results</H2>
 <BR>
 <?
     $db = mysql_connect("localhost", "name", "password");
	 mysql_select_db("covfiles", $db);
	 $query = "Select player_profiles.playerid, player_profiles.alias 
	 		FROM player_profiles WHERE name LIKE '".$_POST['name']."'";
 	$result = mysql_query($query);
	while ($record = mysql_fetch_assoc($result)) {
		while (list($fieldname, $fieldvalue) = each ($record)) {
			echo $fieldname.": <B>".$fieldvalue."</B><BR>";
		}
		echo "<BR>";
	}
	?>
	<BR>
	<A HREF="seachbyname.html">Click here to go back to the search page.</A>
 </BODY>
 </HTML>
The problem with this is I try a search by alias or player id and no matches are found so I am guessing that this code is wrong '".$_POST['name']."' I can't thank you guys enough for this help I can tell I am totaally out of the loop haven't programmed in almost 20 years feal really out of touch.

feyd|use

Code: Select all

tags Cateyes![/color]
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

$_GET is for getting values from the URL
$_POST is for getting values from a form :)


try this:

Code: Select all

<?php

$name = $_POST["name"]    
$db = mysql_connect("localhost", "name", "password"); 
    mysql_select_db("covfiles", $db); 
    $result = @mysql_query("Select player_profiles.playerid, player_profiles.alias 
          FROM player_profiles WHERE name='$name'"); 
    if (mysql_num_rows($result) > 0){
	$row = mysql_fetch_array($result);	
	
	echo $row["name"];
		
	  } 
   ?>
edit... you arnt from from covguild.com are you?
Last edited by John Cartwright on Sun Jun 20, 2004 9:12 pm, edited 1 time in total.
Cateyes
Forum Commoner
Posts: 63
Joined: Mon Jun 14, 2004 5:06 pm

Post by Cateyes »

Thanks will check it out right away I need some manuals for reference nearest bookstore is 4 hours away.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

http://www.php.net

:) thats the only manual i ever needed

edit:

are yu trying to find 1 user? or all users with lets say:

the letter a.

so if you searched a it would return members like

yard
bat
cake
snake
Cateyes
Forum Commoner
Posts: 63
Joined: Mon Jun 14, 2004 5:06 pm

Post by Cateyes »

Still dead in the water I have tried my alias as well as the id# I am assigned by MySQL and it just kicks back the part I have eched and nothing else, like there are no matches. This is damn confusing I was able to make a script that lets me view edit or delete members I thouth this would be easier.

P.S. your code was missing some semicolons but thanks for trying to help me. and I from the clan cov for Crazy Obscene Vandals were a FPS clan mostly.
Last edited by Cateyes on Sun Jun 20, 2004 9:26 pm, edited 1 time in total.
Locked