Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 02-26-2010, 02:10 PM   #1
naval
Registered User
 
Join Date: Dec 2009
Posts: 10
Default connecting flex to php

i m trying to connect a flex application to a php (wamp server)..bt i m unable to do soo
//flex code

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="send_data()">
<mx:Script>
<![CDATA[
import mx.controls.DataGrid

private function send_data():void {
userRequest.send();
}
]]>
</mx:Script>

<mx:Label x="79" y="89" text="username"/>
<mx:Label x="79" y="128" text="rolnumber"/>
<mx:TextInput id="nm" x="153" y="87"/>
<mx:TextInput x="153" y="126" id="roll"/>
<mx:Button x="127" y="191" label="submit" id="sub" click="send_data()"/>


<mx:HTTPService id="userRequest" url="C:\wamp\www\connect.php" useProxy="false" method="POST">
<mx:request xmlns="">
<username>{nm.text}</username><rollnumber>{roll.text}</rollnumber>
</mx:request>
</mx:HTTPService>


</mx:Application>



//php code

<?php
mysql_connect("localhost", "root", "") or die("cannot connect");
mysql_select_db("std_db") or die("cannot select database");

$q="INSERT INTO `std_db`.`student` (`p_key` ,`name` ,`roll`)VALUES (NULL , '$_POST[nm]', $_POST[roll])";
if(mysql_query($q))
echo "sucessfully inserted";
else
echo" error occured";
//if($row=mysql_fetch_array($result))
//{
//echo $row['

?>
naval is offline   Reply With Quote
Old 02-26-2010, 03:54 PM   #2
NoobsArePeople2
Gamefun Engineer
 
Join Date: Nov 2009
Posts: 233
Default

Not super familiar with WAMP but I believe "C:\wamp\www\connect.php" is not the actual url to your server. Should be something like "localhost\connect.php".

Does "C:\wamp\www\connect.php" work when you type it directly into a browser?
NoobsArePeople2 is offline   Reply With Quote
Old 02-26-2010, 04:33 PM   #3
drkstr
Flexpert
 
drkstr's Avatar
 
Join Date: Sep 2006
Location: Seattle, WA: USA
Posts: 1,587
Default

I am very familiar with WAMP, and Noobs is 100% correct. May need to prefix it with, "http://localhost/connect.php", But I don't think it's necessary. If anything, it's good practice.
drkstr is offline   Reply With Quote
Old 02-26-2010, 06:12 PM   #4
naval
Registered User
 
Join Date: Dec 2009
Posts: 10
Default

i changed the adress to "http://localhost/connect.php".......nw there r no errors bt still cnt post ma data in databasee.......ma database is nt updated with databasee....plss help
it shows trasfering data frm local host.........n nthing happens then/

Last edited by naval; 02-26-2010 at 06:24 PM.
naval is offline   Reply With Quote
Old 02-27-2010, 05:36 PM   #5
drkstr
Flexpert
 
drkstr's Avatar
 
Join Date: Sep 2006
Location: Seattle, WA: USA
Posts: 1,587
Default

I am not 100% sure you're HTTPService syntax is correct, because I don't use this method for posting, but I noticed that you are trying to post the vars username and rollnumber, but in your PHP you are referencing nm and roll.

That should at least get you closer, if it does not fix it completely.
drkstr is offline   Reply With Quote
Old 02-28-2010, 05:05 AM   #6
naval
Registered User
 
Join Date: Dec 2009
Posts: 10
Default

Thank you all who replied..............i solved the problem.
naval is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:21 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.