Hi my name is guy.
I would like to set these parameters in flash using a php/mysql database :
button1.maxQuantity
button1.name
button1.option1Name
button1.option1Value
button1.price ;
How would I go about doing that?
Thank You
Guyguyswebdesigns@guyswebdesigns.com
MotionMaker - 08 Apr 2007 20:06 GMT
See Flash help http://livedocs.macromedia.com/flash/8/main/00002336.html
// The LoadVars.sendAndLoad Flash help example
// modified to something like you may want
var send_lv:LoadVars = new LoadVars();
var result_lv:LoadVars = new LoadVars();
result_lv.onLoad = function(success:Boolean)
{
trace(success);
};
button1.onRelease = function()
{
send_lv.maxQuantity = button1.maxQuantity;
send_lv.name = button1.name;
send_lv.option1Name = button1.option1Name;
send_lv.option1Value = button1.option1Value;
send_lv.price = button1.price;
send_lv.sendAndLoad("http://theScript.php", result_lv, "POST");
};
onelotusguy - 09 Apr 2007 22:57 GMT
I am still not geting any results. This is my php Code, what do I need?
$con = mysql_connect($hostname,$username, $password) OR DIE ("Unable to
connect to database! Please try again later.");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db ("$dbname", $con);
// commentbook is the name of the table. If you have a different table name,
use that
//$qResult = mysql_query ("SELECT * FROM Person ORDER BY '0'");
//$qResult = mysql_query ("SELECT * FROM product ORDER BY '1'");
$result = mysql_query ("SELECT * FROM product WHERE templete='product1'");
//$result = mysql_query($query)
// or die("[B]error[/B]: failed to execute query [I]$query[/I]");
//print "content=$desiredContent[content]";
$desiredContent = mysql_fetch_array($result);
print "templete=$desiredContent[templete]";
//$nRows = mysql_num_rows($qResult);
//$rString ="&Totalnumber_of_entries=".$nRows;
?>
onelotusguy - 10 Apr 2007 01:04 GMT
I am still not getting any results.
I followed your example, so If I didn't make amy mistakes with the code you
supplied. The I screwed up the php, her is the code:
$result = mysql_query("SELECT * FROM product ORDER BY Id");
while($row = mysql_fetch_array($result))
{
echo $row['Id'] . " " . $row['templete'] . " " . $row['price'] . " " .
$row['Quantity'] . " " . $row['option1'] . " " . $row['option2'];
echo "<br />";
}
Did I miss some thing?
Guy
MotionMaker - 10 Apr 2007 12:02 GMT
If this is a question of the server script. Could be syntax errors, database
authentication errors, SQL errors, logic errors, web server scripting
configuration issues. For example is it templete or template in your code. Is
it quantity with lower case q or Quantity with uppercase q.
The best way to debug the server script is to create a simple HTML form and
pass the needed variables to it. Then you should have the PHP set so all errors
are returned. Now you can see if you have PHP errors, SQL errors and so on. You
can add special echo statements for debugging.
ONe item I did notice is that the echo statement assumes the PHP script is
providing data to an HTML form. If you add echo statements for debugging, be
sure to remove when returning to using Flash with the script.
The PHP should only echo data in URL var format
&var1=value&var2=valu$var3=value and so on without anything else.
This also means you can have no whitespace before and after the PHP tags.
So the echo "<br/>" needs to go.
$index = 0;
while($row = mysql_fetch_array($result))
{
$index++;
echo "&id" . $index . "=" . $row['Id'];
echo "&templete" . $index . "=" . $row['templete'];
echo "&price" . $index . "=" . $row['price'];
echo "&option1'" . $index . "=" . $row['option1''];
echo "&option2'" . $index . "=" . $row['option2''];
}
onelotusguy - 10 Apr 2007 20:11 GMT
I can get the text into flash from php. like this:
$result = mysql_query ("SELECT * FROM product WHERE Id='1'");
//$result = mysql_query($query)
// or die("[B]error[/B]: failed to execute query [I]$query[/I]");
$desiredContent = mysql_fetch_array($result);
print "Id=$desiredContent[Id]";
This is what I do to bring it into flash:
onClipEvent (load) {
//assuming you have a personal web server and PHP installed locally
loadVariables("http://www.guyswebdesigns.com/PHPfolder/test.php?Id=Id", this,
"GET");
}
How does the php need to coded to fill this out:
button1.onRelease = function()
{
send_lv.maxQuantity = button1.maxQuantity;
send_lv.name = button1.name;
send_lv.option1Name = button1.option1Name;
send_lv.option1Value = button1.option1Value;
send_lv.price = button1.price;
send_lv.sendAndLoad("http://theScript.php", result_lv, "POST");
};
Guy
onelotusguy - 12 Apr 2007 01:19 GMT
Okay so tried modified button insted of using send_lv I used result_lv below
var send_lv:LoadVars = new LoadVars();
var result_lv:LoadVars = new LoadVars();
result_lv.onLoad = function(success:Boolean)
{
trace(success);
};
button1.onRelease = function () {
result_lv.ID=myPayPalItem.ID;
result_lv.maxQuantity = button1.maxQuantity;
// result_lv.name = "templete";
result_lv.name = button1.name;
result_lv.option1Name = button1.option1Name;
result_lv.option1Value = button1.option1Value;
result_lv.price = button1.price;
result_lv.sendAndLoad("http://www.guyswebdesigns.com/PHPfolder/testpage.php?",
result_lv, "POST");
}
The php looks good, so what next?
Guy
MotionMaker - 12 Apr 2007 12:17 GMT
Looks good. Just you want to attach the sending variables to the send LoadVars
object. See attached code.
For the time being you may want to simply send one hard coded variable and use
a copy of the PHP script that returns that value to work out the client server
issues. Then once that is done you can work on the details at both ends.
var send_lv:LoadVars = new LoadVars();
var result_lv:LoadVars = new LoadVars();
result_lv.onLoad = function(success:Boolean)
{
trace(success);
};
button1.onRelease = function () {
send_lv.ID=myPayPalItem.ID;
send_lv.maxQuantity = button1.maxQuantity;
//send_lv.name = "templete";
send_lv.name = button1.name;
send_lv.option1Name = button1.option1Name;
send_lv.option1Value = button1.option1Value;
send_lv.price = button1.price;
send_lv.sendAndLoad("http://www.guyswebdesigns.com/PHPfolder/testpage.php?",
result_lv, "POST");
}
//=======================================
Testing the client server
var send_lv:LoadVars = new LoadVars();
var result_lv:LoadVars = new LoadVars();
result_lv.onLoad = function(success:Boolean)
{
trace("result_lv.onLoad - success:"+ success);
trace ("result_lv.name:"+result_lv.name);
};
button1.onRelease = function () {
send_lv.name = "Joe";
send_lv.sendAndLoad("http://www.guyswebdesigns.com/PHPfolder/testpage.php?",
result_lv, "POST");
}
-----------------------------------------
<?php
echo "&name=" . $_REQUEST['name'];
?>
onelotusguy - 12 Apr 2007 21:51 GMT
Okay I am mistaken And I am sorry.
The button1 is a component, and has certain parameters (button1.maxQuantity
button1.name button1.option1Name button1.option1Value button1.price ;).
Button1 is already active and, dose not need to say (onRelease )or stuff like
that.
if I fill out these parameters (button1.maxQuantity
button1.name button1.option1Name button1.option1Value button1.price ;).
in actionscrit, button1 will pick these parameters up and display them on my
purchase page.
My website(http://www.guyswebdesigns.com/) click on purchase then click add to
cart button and you will see what I mean.
If my PHP is already good to go like the one you had me build (testpage.php).
Then I what I need to no is, how do I create a working storage so that the
button1 can reference the names ex(button1.maxQuantity button1.name) with out
haveing to create a button to call the above parameters?
Sorry for the trouble
Guy
MotionMaker - 13 Apr 2007 12:05 GMT
1. The link seems to show what looks like a DataGrid component. In any case you
have a multi dimensional set of data you need to attach to the send_lv. When
the user selects an action to send the data to the server, you need to assemble
it from the places you have it saved and attach to the send_lv.
2. I am confused about button1. I do not think Flash Component Button
component allow you to add variables. Plus the name does not seem to mean
anything so I cannot correlate it to the screen. Is it the submission button?
Are these the add to cart buttons?
In general looking at the screen, you have items added to a list display which
represents a shopping cart. At some point the user will interact to send the
data to the server. The data needs accessed in a way you can attach to the
send_lv. Perhaps you can simply loop through the display list. Or you could
keep an internal array of objects where each object defines the items.
onelotusguy - 16 Apr 2007 05:54 GMT
The shopping cart window automaticly picks up the add to cart buttons.
So when you click the add to cart button the window pick up the data(no code
required).
Howerver the add to cart button (button1) is a component button that you
set the parameters for(button1.maxQuantity
button1.name
button1.option1Name
button1.option1Value
button1.price ;)
So I give these fields data ex(myPayPalItem.addQuantity = 3;) the cart window
will pick this up.
What I wanted was to use multiple buttons and set the parameters for each one
(button1 button2). And these setting would come from a database. Thus the
reason why I need php and the eventualy down to flash.
Guy
onelotusguy - 17 Apr 2007 21:15 GMT
What I have is a (ANYRD PPCC shoping cart). The buttons for this shopping cart
automaticly fill out the shopping car window. No coding is required unless you
want the buttons to have a specific parameters example below:
button1.maxQuantity = "1" ;
button1.name = "product";
button1.price = "450";
button1.option1Name = "domain";
button1.option1Value = "included";
I do this in action script. When you click button1 with the parameters above,
will fil out my shopping cart window. All I need Is to fill in the quotes
above, with out using any buttons of any kind. I need it to reference php here
is the link of the code and the data it is geting from the data base:
http://www.guyswebdesigns.com/PHPfolder/testpage.php
In action script, this what I would like to see. Flash do an automatic call to
the php data comes back, fills out the code below.
button1.maxQuantity =
button1.name =
button1.price =
button1.option1Name =
button1.option1Value =
Please help?????
Guy
MotionMaker - 18 Apr 2007 01:07 GMT
These are as you say components developed by a company:
"The ANYRD PayPal Cart Components are a set of simple to use flash components
that make it very easy to add self-contained shopping cart capabilites to your
flash movie for use with the PayPal payment service."
Their web site claims they have all the documentation in the Flash help once
you install them. However they have docshttp://anyrd.anyrd.com/docs/ppcc/.
They do not have a user forum to ask questions I noticed but do have an email
address that does not look like it wants inquiries but you could try.
onelotusguy - 18 Apr 2007 04:28 GMT
I can make the Onclipevent work example:
onClipEvent (load) {
//assuming you have a personal web server and PHP installed locally
loadVariables("http://www.guyswebdesigns.com/PHPfolder/test.php?Id=Id", this,
"GET");
This is what it look like in PHP:
print "Id=$desiredContent[Id]";
In the url(http://www.guyswebdesigns.com/PHPfolder/test.php?Id=Id", this,
"GET") The Id=Id is how I fill out my text in the onClipEvent.
How can I use the Id=Id to set an if statment example(if ((1 == 1) ) {
then I will try to fill out the information.
Guy