954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

php curl problem

Guys,

right now i am posting xml to a service running on certain port.
my sample code is

Quote:
$XPost = fread($handle, filesize($xmlfile));

fclose($handle);

$ch = curl_init(); // initialize curl handle
curl_setopt($ch, CURLOPT_VERBOSE, 1); // set url to post to
curl_setopt($ch, CURLOPT_URL, $URL); // set url to post to
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10000);
curl_setopt($ch, CURLOPT_POSTFIELDS, $XPost); // add POST fields
curl_setopt($ch, CURLOPT_POST, 1);
$result = curl_exec($ch);


my problem is some time xml data is ignored .Is this anything related to CURLOPT_TIMEOUT option?what is the prefered value? Anyother solution to optimize the code will be helpful.

note:I will call this function say 50 times 30 times data is correctly loading.sometimes ignored.
prakash_05
Newbie Poster
1 post since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

What does curl_getinfo give? It might give more info why it goes wrong so many times.

colweb
Posting Whiz
318 posts since Nov 2007
Reputation Points: 34
Solved Threads: 52
 

<?php
$connectdb_cygnus = mysql_connect("localhost", "root");
if(!$connectdb_cygnus){
echo "Unable to connect to cygnus: " .mysql_error();
exit;
}

if(!mysql_select_db ("db_cygnus")) {
echo "Unable to select mydb_cygnus: " .mysql_error();
exit;
}

echo "




";

$sql = "SELECT * FROM all_tbl WHERE Color
LIKE '%".$_POST["txtSearch"]."%' ";

$result = mysql_query($sql);
if(!result){
echo "Query Failed " . mysql_error();
exit;
}

if(mysql_num_rows($result) == 20){
echo "";
echo "No data found, Try again";
echo "";
exit;
}


echo "";
echo "Author
Title
Status
Type
";
while($_POST = mysql_fetch_array($result)){
if($bgcolor=='#f1f1f1'){$bgcolor='#ffffff';}else{$bgcolor='f1f1f1';}
echo "
".$_POST["Author"]."
".$_POST["Title"]."
".$_POST["Status"]."
".$_POST["Type"]."

";
}
echo "";
mysql_free_result($result);
?>


Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:\wamp\www\cygnus\search.php on line 43
Author Title Status Type

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\wamp\www\cygnus\search.php on line 58

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in D:\wamp\www\cygnus\search.php on line 71

aafasihah
Newbie Poster
1 post since Mar 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: