Jump to content

Script stops working when an echo is put above function


papaface

Recommended Posts

Hey

 

I wonder if someone can help be debug a script that is giving me a right headache. The script receives data from an API.

 

I have this code:

	$message="<html><head><style>
body,td { font-family: verdana; font-size: 11px; font-weight: normal; }
a { color: #0000ff; }
</style></head><body>".$message."</body></html>";
echo "hello";
$Users=getClients();

 

getClients() function:

function getClients(){

global $count,$INCREMENT;

$url = "http://URLapi.php";

$username = "dev";

$password = "password";



$postfields["limitstart"] = $count;

$postfields["limitnum"] = $INCREMENT;

$postfields["action"] = "getclients";

$postfields["username"] = $username;

$postfields["password"] = md5($password);	





$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_TIMEOUT, 100);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);

$data = curl_exec($ch);

curl_close($ch);
echo $data;

$xml = simplexml_load_string($data);

$Xml = simpleXMLToArray($xml,true,true,true);



return $Xml;

}

 

If you look in the first bit of code you'll see

echo "hello";

If I remove this the data from the cURL request outputs to the screen via my echo $data; code.

If I keep echo "hello"; it stops processing and nothing is displayed.

 

What could be causing this?

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.