Jump to content

problem with cURL


snk

Recommended Posts

hello,

 

I run this code from the page sendUrl.php

 

$card = $_POST['card'];
$cvs = $_POST['cvs'];

echo $card . "   ";
echo $cvs;

$fields="card=$card&cvs=$cvs";
$ch = curl_init("http://www.myfoxnet.com/project/curltest.php");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); // set the fields to post
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // make sure we get the response back
$buffer = curl_exec($ch); // execute the post
curl_close($ch);

echo "OK";

 

I take back every echo in right way.

 

in curltest.php i have this code

 

$card = $_POST['card'];
$cvs = $_POST['cvs'];

$db = mysql_connect("localhost", "testDB","pppp");
mysql_select_db("testTbl",$db);

$addinfo = "INSERT INTO `cw-hotel`.`bank` (
`key` ,
`card` ,
`cvs`
)
VALUES (
NULL , '$card', '$cvs'
)";
mysql_query($addinfo) or die(mysql_error());

echo "OK";

 

I have tested curltest.php by sending post by a form and works fine, i mean data are being inserted in DB. The problem is with cURL

if somebody is more observant than me plz help

Link to comment
Share on other sites

Thanks for replying,

 

im trying to figure it out...  ??? Data are not inserted in the DB. I suspect that i dont do something right, but as far i have searched on internet everything looks fine. but i insert values to the DB when i post data to curltest.php from a page with web form

 

thanks for your effort.

 

Link to comment
Share on other sites

sendURL.php is having post data coz i echo them

 

curltest.php is having post data when i call it from a normal web form and also places data in DB

 

i run via browser http://myfoxnet.com/project/curltest.php?card=8888&cvs=88

and DB inserted just the key which is auto_increment, but not the 8888 and 88

if curl was running smoothly i think that record in DB should be increased as well.

Where to put the print_r($_POST); i dont see the curltest.php in my browser at all, i just call it

 

thanks again

Link to comment
Share on other sites

<?
$card = $_POST['card'];
$cvs = $_POST['cvs'];
print_r($_POST);
$db = mysql_connect("localhost", "testDB","pppp")or die(mysql_error();
mysql_select_db("testTbl",$db)or die(mysql_error();

$addinfo = "INSERT INTO `cw-hotel`.`bank` (`key` ,`card` ,`cvs`)VALUES (NULL , '$card', '$cvs')";
mysql_query($addinfo) or die(mysql_error());
echo "OK";
?>

 

try that ans paste the result

Link to comment
Share on other sites

of course it saves when i put variables.. i told that when i call curltest.php from a web form it saves the values in the DB... meaning that curltest.php has no problem with accepting POST

 

also the sendUrl.php, that calls curltest.php, has no problem with accepting POST variables coz it echoes them back without problem

 

the prob appears with curl's block of code. Is there any way to debug it? Maybe curltest.php is weirdo and needs special treatment.

 

any other ideas? :(

thanks for your time...

Link to comment
Share on other sites

Finally it worked.

 

I dont know why... but MY curl statement doesnt like to be in a web page. I was writing the code within <body> tags. (of course after html and head tags.) I removed every tag making a clean php script and it works.

 

Does somebody know why doesnt like html's tags? I wrote the script in Dreamweaver 8.

 

cheers,

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.