Hi, I have been creating a simple flash site and I need to use PHP and MySql, which I have never done. And I really need help.
I've created a database but I can't get my action script to send my variable to my PHP code. I think my Mysql data base has been set up wrong, but because I have never done this before I don't know what I am doing wrong.
Please can some help me. I have not slept for 3 days
If anyone can help me i will be eternally greatful.
This is how for I've got
Action script code
[code=actionscri pt]
function sendmail() {
var dbVar = new LoadVars();
db_path = "localhost/shop.php";
for (var i = 0; i<_root.mycart. length; i++) {
dbVar.itemdent = "ID: "+_root.mycart. getItemAt(i).id ;
dbVar.ItemSize = "Size: "+_root.mycart. getItemAt(i).si ze;
dbVar.ItemProdu ct = "Product: "+_root.mycart. getItemAt(i).pr oduct;
dbVar.ItemQut = "Quantity: "+_root.mycart. getItemAt(i).qu t;
dbVar.ItemPrice = "Price: "+_root.mycart. getItemAt(i).pr ice;
}
dbVar.sendAndLo ad(db_path, dbVar, "POST");
trace(dbVar);
}
_root.billing_m ov.send_bt.onRe lease = function() {
sendmail();
};[/code]
PHP code
[code=php]<?php
// Make a MySQL Connection
require("db.php ");
//creating a var
$var_itemdent = $_POST['itemdent'];
$var_itemQut = $_POST['itemQut'];
$var_itemProduc t = $_POST['itemProduct'];
$var_itemSize = $_POST['itemSize'];
$var_itemPrice = $_POST['itemPrice'];
/* Strip any escape characters etc */
$var_itemdent = stripslashes($v ar_itemdent);
$var_itemQut = stripslashes($v ar_itemQut);
$var_itemProduc t = stripslashes($v ar_itemProduct) ;
$var_itemSize = stripslashes($v ar_itemSize);
$var_itemPrice = stripslashes($v ar_itemPrice);
// Insert a row of information into the table "customer orders"
$q1 = "INSERT INTO customer orders (id, qut, products, size, price)
VALUES ('$var_itemdent ', '$var_itemQut', '$var_itemProdu ct', '$var_itemSize' , '$var_itemPrice ')";
echo $q1;
mysql_close($co n);
?>[/code]
[Please use CODE tags when posting source code. Thanks! --pbmods]
I've created a database but I can't get my action script to send my variable to my PHP code. I think my Mysql data base has been set up wrong, but because I have never done this before I don't know what I am doing wrong.
Please can some help me. I have not slept for 3 days
If anyone can help me i will be eternally greatful.
This is how for I've got
Action script code
[code=actionscri pt]
function sendmail() {
var dbVar = new LoadVars();
db_path = "localhost/shop.php";
for (var i = 0; i<_root.mycart. length; i++) {
dbVar.itemdent = "ID: "+_root.mycart. getItemAt(i).id ;
dbVar.ItemSize = "Size: "+_root.mycart. getItemAt(i).si ze;
dbVar.ItemProdu ct = "Product: "+_root.mycart. getItemAt(i).pr oduct;
dbVar.ItemQut = "Quantity: "+_root.mycart. getItemAt(i).qu t;
dbVar.ItemPrice = "Price: "+_root.mycart. getItemAt(i).pr ice;
}
dbVar.sendAndLo ad(db_path, dbVar, "POST");
trace(dbVar);
}
_root.billing_m ov.send_bt.onRe lease = function() {
sendmail();
};[/code]
PHP code
[code=php]<?php
// Make a MySQL Connection
require("db.php ");
//creating a var
$var_itemdent = $_POST['itemdent'];
$var_itemQut = $_POST['itemQut'];
$var_itemProduc t = $_POST['itemProduct'];
$var_itemSize = $_POST['itemSize'];
$var_itemPrice = $_POST['itemPrice'];
/* Strip any escape characters etc */
$var_itemdent = stripslashes($v ar_itemdent);
$var_itemQut = stripslashes($v ar_itemQut);
$var_itemProduc t = stripslashes($v ar_itemProduct) ;
$var_itemSize = stripslashes($v ar_itemSize);
$var_itemPrice = stripslashes($v ar_itemPrice);
// Insert a row of information into the table "customer orders"
$q1 = "INSERT INTO customer orders (id, qut, products, size, price)
VALUES ('$var_itemdent ', '$var_itemQut', '$var_itemProdu ct', '$var_itemSize' , '$var_itemPrice ')";
echo $q1;
mysql_close($co n);
?>[/code]
[Please use CODE tags when posting source code. Thanks! --pbmods]
Comment