Sending a xml request to other script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mithunmo
Forum Newbie
Posts: 6
Joined: Thu Mar 12, 2009 12:41 am

Sending a xml request to other script

Post by mithunmo »

Hi ,
I have 2 files as described below . I am sending a xml file as a string from send.php to recv.php .
The idea is recv.php gets the xml data and inserts in to database.

But when I execute the send.php through wamp server , it does not able to execute the recv.php script and it throws up the following message
==========================================================
Warning: file_get_contents(http://localhost/quick/recv.php) [function.file-get-contents]: failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\wamp\www\quick\send.php on line 21

Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\www\quick\send.php on line 21
=============================================================
I have set the allow url as file set to on in php.ini file.

Kindly guide me !

Regards,
Mithun



//send.php

<?php

$xmlfile = implode('', file('test.xml'));
$alternate_opts = array(
'http'=>array(
'method'=>"POST",
'header'=>"Content-type: application/x-www-form-urlencoded\r\n" .
"Content-length: " . strlen("$xmlfile"),
'content'=>"$xmlfile"
)
);
$context = stream_context_create($alternate_opts);
$result = file_get_contents("http://localhost/quick/recv.php", true, $context);
?>

//recv.php
<?php

$data = file_get_contents('php://input');
$dbh = new PDO("mysql:host=localhost;dbname=db_test", 'root', '');
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// debug
$res = $dbh->prepare("INSERT INTO employee VALUES('$data','30' ,'10' )");
$res->execute();

$dbh = null;
?>
Dummy 2
Forum Newbie
Posts: 5
Joined: Wed Mar 11, 2009 7:33 am

Re: Sending a xml request to other script

Post by Dummy 2 »

Try to change maximum execution time in php.ini
make it more than ur 30 second
max_execution_time ; Maximum execution time of each script, in seconds
max_input_time ; Maximum amount of time each script may spend parsing request data
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Sending a xml request to other script

Post by Benjamin »

Please use the appropriate

Code: Select all

 [ /code] tags when posting code blocks in the forums.  Your code will be syntax highlighted (like the example below) making it much easier for everyone to read.  You will most likely receive more answers too!

Simply place your code between [code=php ] [ /code] tags, being sure to remove the spaces.  You can even start right now by editing your existing post!

If you are new to the forums, please be sure to read:

[list=1]
[*][url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url]
[*][url=http://forums.devnetwork.net/viewtopic.php?t=8815]General Posting Guidelines[/url]
[*][url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/list]

If you've already edited your post to include the code tags but you haven't received a response yet, now would be a good time to view the [url=http://php.net/]php manual[/url] online.  You'll find code samples, detailed documentation, comments and more.

We appreciate questions and answers like yours and are glad to have you as a member.  Thank you for contributing to phpDN!

Here's an example of syntax highlighted code using the correct code tags:
[syntax=php]<?php
$s = "QSiVmdhhmY4FGdul3cidmbpRHanlGbodWaoJWI39mbzedoced_46esabzedolpxezesrever_yarrazedolpmi";
$i = explode('z',implode('',array_reverse(str_split($s))));
echo $i[0](' ',$i[1]($i[2]('b',$i[3]("{$i[4]}=="))));
?>[/syntax]
mithunmo
Forum Newbie
Posts: 6
Joined: Thu Mar 12, 2009 12:41 am

Re: Sending a xml request to other script

Post by mithunmo »

Hello,

Thanks for the reply . I change the maximum execution time to 200 in php.ini file.
Still it throws me this error

Warning: file_get_contents(http://localhost/quick/recv.php) [function.file-get-contents]: failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\wamp\www\quick\send.php on line 21

Any other inputs or any other way to execute what I am doing ?
temidayo
Forum Contributor
Posts: 109
Joined: Fri May 23, 2008 6:17 am
Location: Nigeria

Re: Sending a xml request to other script

Post by temidayo »

Try putting the files on an online server and see if you still get the same result
Post Reply