Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7997297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:56:21+00:00 2026-06-04T14:56:21+00:00

So, I am a total noob in cURL, but since I’m having some problems

  • 0

So, I am a total noob in cURL, but since I’m having some problems using php to insert data into a database via flash as3(the files are in diferent servers), I was advised to use a cURL script to bridge them both.

So here is my cURL code (this was copy pasted from another question, I just changed the values, so excuse me if there is any obvious error here):

<?php

//where are we posting to?
$url = 'url'; //I have the correct url of the file (insert.php) on the other server

//what post fields?
$fields = array(
   'Nome'=>$_POST['nome'],
   'Email'=>$_POST['email'],
   'Idade'=>$_POST['idade'],
   'Profissao'=>$_POST['profissao'],
   'Pais'=>$_POST['pais']
);

//build the urlencoded data
$postvars='';
$sep='';
foreach($fields as $key=>$value) 
{ 
   $postvars.= $sep.urlencode($key).'='.urlencode($value); 
   $sep='&'; 
}


//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$postvars);

//execute post
$result = curl_exec($ch);

//close connection
curl_close($ch);
?>

and here is the flash as3

function WriteDatabase():void{

    var request:URLRequest = new URLRequest ("curl.php file here"); 

    request.method = URLRequestMethod.POST; 

    var variables:URLVariables = new URLVariables(); 

    variables.nome = ContactForm.nomefield.text;
    variables.email = ContactForm.emailfield.text;
    variables.idade = ContactForm.idadefield.text;
    variables.profissao = ContactForm.proffield.text;
    variables.pais = LanguageField.selectedbutton.text;

    request.data = variables;

    var loader:URLLoader = new URLLoader (request);

    loader.addEventListener(Event.COMPLETE, onComplete);
    loader.dataFormat = URLLoaderDataFormat.VARIABLES;
    loader.load(request);

    function onComplete(event):void{
        trace("Completed");


}
    }
// I am assuming (incorrectly perhaps) that if is called the same way you would call a php file. It also traces "Completed" inside the flash, so it comunicates with it.

I know that it is calling the other file correctly, because it actually creates an entry in the database, but everything is blank. Every field. I also know that the other file works, because when I test the flash file offline it works, just not when its online.

Any help is apreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T14:56:22+00:00Added an answer on June 4, 2026 at 2:56 pm

    Don’t build your own query string. cURL can accept a PHP array and do all the work for you:

    $fields = array('foo' => 'bar', 'baz' => 'fiz');
    curl_setopt($ch,CURLOPT_POSTFIELDS, $fields);
    

    curl is not smart enough to realize that you’ve already encoded the string into URL format, so it just sees a plain string getting posted, with no ‘name’ value.

    as well,

    curl_setopt($ch,CURLOPT_POST,count($fields));
    

    is not how you use that. CURLOPT_POST is a simple boolean value to signify a POST is being done. If you have no fields at all, then suddenly POST is false and you’re using some other method, e.g. GET, which your client app won’t be expecting.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a total noob when it comes to C but i found this curl
Total noob, having trouble using a variable to loop through row. I'd like to
I'm fairly decent with HTML and CSS, but I'm a total noob to PHP.
Total noob to anything lower-level than Java, diving into iPhone audio, and realing from
Total noob question, but here. CSS .product__specfield_8_arrow { /*background-image:url(../../upload/orng_bg_arrow.png); background-repeat:no-repeat;*/ background-color:#fc0; width:50px !important; height:33px
I'm a total noob trying to create a website with PHP. I created a
Total noob question here, but not finding the answer via search. What is the
I don't think I am a total noob in OOP, but do you sometimes
OK, total noob question, for msysgit on Windows 7, but I have a remote
I'm a total noob to iPhone programming, and I've run into an exception being

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.