Lingobaby Posted April 3, 2007 Share Posted April 3, 2007 Greetings, I'm still a bit green when it comes to PHP so please forgive my ignorance here if I'm approaching my problem the wrong way... Long story short, I'm creating an internal application that submits loan application fields to a banks URL via HTTP Post. This code runs within Joomla which I've never had a problem with before. Copied below is the base case which I know works when called by itself. <?php $content = "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>\r\n" ."<Application>\r\n" ."<Identification>\r\n" ."<TransactionId>8</TransactionId>\r\n" ."<TimeStamp>20070329171109</TimeStamp>\r\n" ."</Identification>\r\n" ."</Application>\r\n"; $headers = array( "Content-type: application/atom+xml" ); // Use curl to post $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://the_bank_url/newapp.do"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_POSTFIELDS, $content); $data = curl_exec($ch); if (curl_errno($ch)) { print curl_error($ch); } else { curl_close($ch); } // $data contains the result of the post... echo $data; ?> Here lies the problem... when a query is run before running the above code to input variables into the XML, I receive the following message "Parse error: syntax error, unexpected T_STRING in...." If I comment out the line curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); it displays the result in the browser with no problem along with the rest of the form. Here is a snippet of the rest of the application causing the problem. $this->execPieceByName('ff_InitLib'); global $record_id; global $query, $rows; $record_id = ff_getParam('ff_rid'); /* Now get the date from the log file with proper id*/ $query = "select id, submitted as valx from jos_facileforms_records where id = '"; $query .= $record_id; $query .= "'"; $rows = ff_select($query); $cnt = count($rows); foreach ($rows as $row ) { switch ($row->id) { /* The echo's are for debugging purposes only */ case $record_id : ff_setValue('submitted_date', $row->valx); $submitted_date = $row->valx; default : break; } // switch }//for /* Set the Submition Results */ ff_setValue('application_id', $record_id); $application_id = $record_id; /* Now get all the values from the log file with proper id*/ $query = "select name, value as valx from jos_facileforms_subrecords where record = '"; $query .= $record_id; $query .= "'"; $rows = ff_select($query); $cnt = count($rows); foreach ($rows as $row ) { switch ($row->name) { case 'prim_first_name' : ff_setValue('prim_first_name', $row->valx); $prim_first_name = $row->valx; break; case 'prim_middle_name' : ff_setValue('prim_middle_name', $row->valx); $prim_middle_name = $row->valx; break; default : break; } // switch }//for $content = "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>\r\n" ."<Application>\r\n" ."<Identification>\r\n" ."<TransactionId>$record_id</TransactionId>\r\n" ."<TimeStamp>$submitted_date</TimeStamp>\r\n" ."</Identification>\r\n" ."<ReferenceNumber>$record_id</ReferenceNumber>\r\n" ."<Comments>\r\n" ."Ignore this Post.\r\n" ."</Comments>\r\n" ."</Application>\r\n"; $headers = array( "Content-type: application/atom+xml" ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://the_bank_url/newapp.do/newapp.do"); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_POSTFIELDS, $content); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $data = curl_exec($ch); if (curl_errno($ch)) { print curl_error($ch); } else { curl_close($ch); } // $data contains the result of the post... echo "Returned result is " . $data . "<br>\n"; Again, when I comment out CURLOPT_RETURNTRANSFER everything works like a charm. If someone could point me in the direction as to why this causing me headaches I would be forever grateful! Thanks in advance, Jason Link to comment https://forums.phpfreaks.com/topic/45446-curlopt_returntransfer-and-unexpected-t_string-error/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.