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.

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

<?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 "
<table cellspacing='0' cellpadding='3'><tr><td>
<br>
<form method='POST' name='frmSearch' action='search.php'>
<input type='text' name='txtSearch' size='30'>
<input type='submit' name='cmdSearch' value='Search'>
</form>
</td></tr></table>";

$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 "<table cellspacing='0' cellpadding='3'><tr><td>";
echo "No data found, Try again";
echo "</td></tr></table>";
exit;
}


echo "<table cellspacing='0' cellpadding='3'>";
echo "<tr>
<td width='20%' bgcolor= 'FF0033'><b>Author</b></td>
<td width='30%' bgcolor= 'FF0033'><b>Title</b></td>
<td width='20%' bgcolor= 'FF0033'><b>Status</b></td>
<td width='10%' bgcolor= 'FF0033'><b>Type</b></td>
</tr>";
while($_POST = mysql_fetch_array($result)){
if($bgcolor=='#f1f1f1'){$bgcolor='#ffffff';}else{$bgcolor='f1f1f1';}
echo "
<tr>
<td width='20%' bgcolor='$bgcolor'>".$_POST["Author"]."</td>
<td width='30%' bgcolor='$bgcolor'>".$_POST["Title"]."</td>
<td width='20%' bgcolor='$bgcolor'>".$_POST["Status"]."</td>
<td width='10%' bgcolor='$bgcolor'>".$_POST["Type"]."</td>
</tr>
<tr>
";
}
echo "</table>";
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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.