473,513 Members | 2,469 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Connecting to MySQL via PHP using ActionScript

34 New Member
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
Expand|Select|Wrap|Line Numbers
  1. function sendmail() {
  2.     var dbVar = new LoadVars();
  3.     db_path = "localhost/shop.php";
  4.     for (var i = 0; i<_root.mycart.length; i++) {
  5.         dbVar.itemdent = "ID: "+_root.mycart.getItemAt(i).id;
  6.         dbVar.ItemSize = "Size: "+_root.mycart.getItemAt(i).size;
  7.         dbVar.ItemProduct = "Product: "+_root.mycart.getItemAt(i).product;
  8.         dbVar.ItemQut = "Quantity: "+_root.mycart.getItemAt(i).qut;
  9.         dbVar.ItemPrice = "Price: "+_root.mycart.getItemAt(i).price;
  10.     }
  11.     dbVar.sendAndLoad(db_path, dbVar, "POST");
  12.     trace(dbVar);
  13. }
  14. _root.billing_mov.send_bt.onRelease = function() {
  15.     sendmail();
  16. };
PHP code
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // Make a MySQL Connection
  3. require("db.php"); 
  4. //creating a var
  5. $var_itemdent = $_POST['itemdent'];
  6. $var_itemQut = $_POST['itemQut'];
  7. $var_itemProduct = $_POST['itemProduct'];
  8. $var_itemSize = $_POST['itemSize'];
  9. $var_itemPrice = $_POST['itemPrice'];
  10.  
  11. /* Strip any escape characters etc */
  12. $var_itemdent = stripslashes($var_itemdent);
  13. $var_itemQut = stripslashes($var_itemQut);
  14. $var_itemProduct = stripslashes($var_itemProduct);
  15. $var_itemSize = stripslashes($var_itemSize);
  16. $var_itemPrice = stripslashes($var_itemPrice);
  17.  
  18. // Insert a row of information into the table "customer orders"
  19. $q1 = "INSERT INTO customer orders (id, qut, products, size, price)
  20. VALUES ('$var_itemdent', '$var_itemQut', '$var_itemProduct', '$var_itemSize', '$var_itemPrice')";
  21. echo $q1;
  22. mysql_close($con);
  23. ?>
[Please use CODE tags when posting source code. Thanks! --pbmods]
Jun 27 '07 #1
8 2327
pbmods
5,821 Recognized Expert Expert
Changed thread title to better describe the problem.
Jun 27 '07 #2
Zarwadi
34 New Member
Changed thread title to better describe the problem.
Thanks for you help I'm new here
Jun 27 '07 #3
pbmods
5,821 Recognized Expert Expert
Heya, Zarwadi.

Thanks for you help I'm new here
Happens to the best of us.

-----

First things first, get some sleep.

Ok then.

The major problem I see is that you echo your SQL query, but you never actually send it. You will want to add these lines to your code after you define $sql:
Expand|Select|Wrap|Line Numbers
  1. if(! mysql_query($sql))
  2.     exit(mysql_error());
  3.  
Jun 27 '07 #4
ak1dnar
1,584 Recognized Expert Top Contributor
Hi Zarwadi,
Please let me know whether you could able to print those USER INPUTS from PHP end.before we enter them to MySQL.

Something like this.

Expand|Select|Wrap|Line Numbers
  1. $var_itemdent = $_POST['itemdent'];
  2. echo $var_itemdent ;
  3.  
Thanks,
-Ajaxrand
Jun 27 '07 #5
Zarwadi
34 New Member
Hi there I get 5 hours sleep, thanks for caring. Well I used the code you sent me and this was came up

Query was empty.

So it seems the action script code is not begging sent to the PHP. I know the LoadVar dbVar is working so, what am i doing wrong.

kind regards Zarwadi
Jun 27 '07 #6
Zarwadi
34 New Member
Hi thanks for getting back to me so quickly. I tried the
echo $var_itemdent ; and nothing has came up. Someone else told me to try this,

if(! mysql_query($sql))
{
exit(mysql_error());
}
I did, and this come up
Query was empty
So it seems the actionscript is not sending the LoadVar
dbVar to the PHP. i'm confused

If you can help like I said before I would be very very greatful

Zarwadi
Jun 27 '07 #7
ak1dnar
1,584 Recognized Expert Top Contributor
Hi thanks for getting back to me so quickly. I tried the
echo $var_itemdent ; and nothing has came up. Someone else told me to try this,

if(! mysql_query($sql))
{
exit(mysql_error());
}
I did, and this come up
Query was empty
So it seems the actionscript is not sending the LoadVar
dbVar to the PHP. i'm confused

If you can help like I said before I would be very very greatful

Zarwadi
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // Make a MySQL Connection
  3. //require("db.php"); 
  4. //creating a var
  5.  
  6. # we will forget about Entering data to MySQL for now.-Ajaxrand
  7.  
  8. $var_itemdent = $_POST['itemdent'];
  9. $var_itemQut = $_POST['itemQut'];
  10. $var_itemProduct = $_POST['itemProduct'];
  11. $var_itemSize = $_POST['itemSize'];
  12. $var_itemPrice = $_POST['itemPrice'];
  13.  
  14. /* Strip any escape characters etc */
  15. $var_itemdent = stripslashes($var_itemdent);
  16. $var_itemQut = stripslashes($var_itemQut);
  17. $var_itemProduct = stripslashes($var_itemProduct);
  18. $var_itemSize = stripslashes($var_itemSize);
  19. $var_itemPrice = stripslashes($var_itemPrice);
  20.  
  21. # If you cant echo the user inputs, which getting from Action Script
  22. # means the problem is with your Action Script
  23. # so fix it up.
  24. echo $var_itemdent;
  25. # rest of the code goes here
  26. echo $var_itemPrice;
  27.  
  28.  
  29. /*
  30. // Insert a row of information into the table "customer orders"
  31. $q1 = "INSERT INTO customer orders (id, qut, products, size, price)
  32. VALUES ('$var_itemdent', '$var_itemQut', '$var_itemProduct', '$var_itemSize', '$var_itemPrice')";
  33. echo $q1;
  34. mysql_close($con);
  35. */
  36. ?>
Jun 27 '07 #8
Zarwadi
34 New Member
Hi I think i've found the problem, but I do not under stand it, do you know what this means

Re: [jQuery] Bug Report - Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE), it has some thing to do with my PHP

kind regards
zarwdi
Jun 27 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

0
3621
by: Google Mike | last post by:
After a lot of thought and research, and playing with FreeTDS and InlineTDS, as well as various ODBC connections, I have determined that the fastest and cheapest way to get up and going with PHP on...
3
6154
by: kamilla | last post by:
I have a mysql 3.5 server installed on a suse linux 8.1, with address 10.0.0.100. Now I want to access that db from a W2K pc, address 10.0.0.200. I am able to ping 10.0.0.100, but I cannot connect...
4
1784
by: CodeImp | last post by:
A simple app I quickly wrote to try getting info from a database. Here is the first part of its code. The rest of the code is irellevant. using System; using System.Data; using...
3
2227
by: Jeremy Dillinger | last post by:
I am trying to design a program that will use data from a MySQL database. Currently all the data is being used with PHP scripts from a website. I am also trying to build a software solution that...
0
1110
by: grouchy | last post by:
Hello everyone, hope u r all well. Got a bit of a simple question. I have a textArea box (mesgArea.text) where a user can write a simple message and then press a send button ("sendMsg"). All i...
3
2688
by: Paradox Synthesist | last post by:
hi, i am a newbie to asp.net and have started learning mainly from websites. i have a question which IS very silly and trivial. ...
3
2427
by: Zarwadi | last post by:
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...
8
4715
by: Ananthu | last post by:
Hi I have done all the codings part for connecting mysql with java in eclipse environment. Coding Part: import java.sql.Connection; import java.sql.DriverManager; public class...
0
7158
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7380
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7523
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5683
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5085
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1592
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.