473,786 Members | 2,420 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 2346
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($sq l))
{
exit(mysql_erro r());
}
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($sq l))
{
exit(mysql_erro r());
}
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_ILLEG AL_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
3639
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 Linux, connecting to MS SQL Server, unless it was already pre-installed by your Linux installation, is to build your own multithreaded TCP socket server on Windows and connect to it through the socket API in PHP on Linux (if you have installed...
3
6173
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 to the db, and get error 2013. I have tried with MySQL Administrator 1.0 and also with ODBC. The db on linux has grant all on *.* to ''@'10.0.0.%' and also tried .... to root@10.0.0.200 and others seen on posted messages. I can access that db...
4
1800
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 System.Data.SqlClient; using System.Threading; namespace TestSQL { class Class1
3
2247
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 can use the same data. I have gone through all the data connectors in Visual Basic.net and none of them have the options for connecting to MySQL. Does anybody know how I would go about doing this? Thanks in advance! Jeremy
0
1125
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 really need is when that user presses the sendMsg button, for the message to be stored in the field called "messagedescription" in the "messages" table in mySQL database. Thus when i look in the actual database the message typed by the user in...
3
2704
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. http://msdn2.microsoft.com/en-us/library/system.data.odbc.odbcconnectionstringbuilder.dsn(VS.80).aspx i looked through this url to see how could i connect to a mysql database...where does the dsn figure out? why do i need to give it? i cant see any dsn specified anywhere on the database control panel. i am a...
3
2445
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 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...
8
4743
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 MysqlConnect {
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10363
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9961
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8989
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7512
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5397
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4066
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 we have to send another system

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.