473,803 Members | 4,391 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help with php5 and cURL


I am trying to post an array using cURL from one PHP page to another. I
can't figure out how to correctly post and read the array on the page
that actually receives it. Here is what I have...

$session = curl_init();

curl_setopt( $session, CURLOPT_URL,
"https://www.myswebsite. com/receiving.php" );
curl_setopt( $session, CURLOPT_HEADER, false );
curl_setopt( $session, CURLOPT_POST, true );
curl_setopt( $session, CURLOPT_POSTFIE LDS, $_POST['fields'] );
curl_setopt( $session, CURLOPT_RETURNT RANSFER, true );
curl_setopt( $session, CURLOPT_SSL_VER IFYPEER, false );
curl_setopt( $session, CURLOPT_USERPWD , $sslpassword );
curl_setopt( $session, CURLOPT_HTTPAUT H, CURLAUTH_BASIC );

$returned = curl_exec( $session );
curl_close( $session );
echo $returned;

On the receiving page this echos zero ...

$numFormFields = count( $_POST['fields'] );
Apr 12 '06 #1
1 1521

Hi Mickey,

Two things:

1) Check that you've got the syntax of this right:
curl_setopt( $session, CURLOPT_POSTFIE LDS, $_POST['fields'] );


If $_POST['fields'] currently contains an array, you probably want to do
something like this:

curl_setopt( $session, CURLOPT_POSTFIE LDS,
array("fields"= >$_POST['fields']));

Otherwise you aren't passing through a name the array can be referred to
using on the other side.

2) I don't know how PHP will handle you trying to pass an array (PHP
data structure) over HTTP. You may need to use the serialize/unserialize
functions on the data on the way in/out (respectively).

Cheers,
Andy
--
Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
http://www.gphpedit.org | PHP editor for Gnome 2
http://www.andyjeffries.co.uk | Personal site and photos

Apr 13 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2770
by: Jason Morehouse | last post by:
Hello, Just wondering if anyone is using the apache worker module with php? I've complied php5 with zend threadsafe support, and apache2 with the MPM worker module on a Linux box. Everything seems sweet. mysqli_thread_safe() reports true... anyone know if this configuration may include modules that aren't threadsafe? with-apxs2=/usr/local/apache2/bin/apxs with-gd enable-gd-native-ttf
4
1829
by: Daniel Andersen | last post by:
Hey, We are in the process of rewriting our internal management system (which was written in PHP4), and figured this would be a good time to migrate to PHP5 to get all the OO goodness it has to offer :) I am running php 5.0.3 on apache 1.3.something under slackware linux. Unfortunately I frequently get segfaults from php scripts, and they are not even scripts that do anything fancy or special. For example, in one script i got a...
13
6678
by: Gary Quiring | last post by:
I need to create an XML string using PHP5. The examples I have followed seem to be using out dated libary calls. I tried new_xmldoc() and new DomDocument. Both get undefined errors. How do I create an XML string where it will look something like this: <response> <data> <parts> <part> <number>bla</number>
5
5697
by: voronwae | last post by:
Hi folks. Either I'm missing something really obvious (most likely) or I'm missing something really subtle. I've been building up a machine as an IMP webmail server, with php 5.1.2, cyrus-sasl, openldap, imap, fileinfo, mod_perl, sqlite, horde, Berkeley DB and PostgreSQL, among others, on top of an old Potatoe machine that was already alive and in production so I just went with it. Everything worked great up until the installation of...
3
2639
by: Chuck Renner | last post by:
Please help! This MIGHT even be a bug in PHP! I'll provide version numbers and site specific information (browser, OS, and kernel versions) if others cannot reproduce this problem. I'm running into some PHP behavior that I do not understand in PHP 5.1.2. I need to parse the HTML from the following carefully constructed URI:
1
1782
by: Skeleton Man | last post by:
Hi all, I'm trying to compile php 5.2.0 under FreeBSD 6. If I use the version of OpenSSL that came installed with FreeBSD (0.97a) then it builds okay and then segfaults on make install when it gets to installing pear. I tried building with the latest OpenSSL and that causes make to fail with an error about libmysql.a !! The reason I am building with OpenSSL is because I need to access secure sites (https://) via HTTP_Client and cURL....
1
1650
by: devranger | last post by:
Hello, I am in the process of learning PHP CURL and in doing some test examples I am having some issues with CURL that I do not fully understand. I am doing a test to use CURL to post and return results from "http://powersports.honda.com/dealer_locator/dealer_locator.asp" However it does not appear to be returning results from the CURL post action. What CURL appears to be doing is finding the page...
1
4910
by: c1pkw | last post by:
Hi there, I’m having a real heap of trouble with PHP and cURL My aim is to use this code (or something like it) to submit 2 fields to a remote server (using GET) and receive back 6 fields (again with GET). When I run the function below, I get back a 401 unauthorized error although the Username and Password are correct. Presumably then, they are not reaching the remote server at all or in the correct state. Problem is, I know so...
3
2636
by: k.rollman | last post by:
I am having a problem using cURL to create an https connection on a non-standard port (440). Using curl_setopt to set the port to 440 has no effect, and I get the following from curl's verbose output. * About to connect() to xxx.xxx.xxx.xxx port 443 * Connected to xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx) port 443 If I put ':440' in the url, I get the following and an error code of 7. * About to connect() to xxx.xxx.xxx.xxx port 440
0
9562
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10542
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
10309
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10068
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
9119
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
7600
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
5625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3795
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2968
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.