php-general Digest 7 Feb 2010 15:22:26 -0000 Issue 6578

2010-02-07 Thread php-general-digest-help

php-general Digest 7 Feb 2010 15:22:26 - Issue 6578

Topics (messages 301856 through 301860):

Problem with blocking streams in PHP
301856 by: Phani Raju

Issue with blocked socket stream
301857 by: Phani Raju

Re: simplexml - can it do what I need?
301858 by: TerryA
301859 by: Carlos Medina

Hi list --- justa simple question
301860 by: ebhakt

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
I am trying to open a blocking stream using fsockopen. I want to write and read 
XML input/output from a server. After opening the steam I will send a XML 
request to server using the stream. Once this request is sent, I want to keep 
listening on the port indefinitely. 



I tried using blocking stream for this with a huge timeout. But had no success 
as it was not waiting for such a long period.



Code:

$parser = xml_parser_create(UTF-8);

if($stream = @fsockopen($host, $port, $errorno, $errorstr, $timeout)) {

stream_set_blocking($stream, 1);

stream_set_timeout($stream, TIMEOUT);

fwrite($stream, $xml.\n);

sleep(2);

while (!feof($stream)) {

$data = fread($stream, 1024);

xml_parse($parser, $data, feof($stream));

}

}



$xml has the xml to be sent. TIMEOUT is set to 3600*24 and $timeout is set to 
300. As it is a blocking stream, till the data is not arrived, feof should not 
happen. But in this case, the stream is not waiting and returning eof. What is 
the problem with this code?



I tried using even stream_select but faced same issue. ---End Message---
---BeginMessage---
I am trying to open a blocking stream using fsockopen. I want to write and read 
XML input/output from a server. After opening the steam I will send a XML 
request to server using the stream. Once this request is sent, I want to keep 
listening on the port indefinitely.



I tried using blocking stream for this with a huge timeout. But had no success 
as it was not waiting for such a long period.



Code:

$parser = xml_parser_create(UTF-8);

if($stream = @fsockopen($host, $port, $errorno, $errorstr, $timeout)) {

stream_set_blocking($stream, 1);

stream_set_timeout($stream, TIMEOUT);

fwrite($stream, $xml.n);

sleep(2);

while (!feof($stream)) {

$data = fread($stream, 1024);

xml_parse($parser, $data, feof($stream));

}

}



$xml has the xml to be sent. TIMEOUT is set to 3600*24 and $timeout is set to 
300. As it is a blocking stream, till the data is not arrived, feof should not 
happen. But in this case, the stream is not waiting and returning eof. What is 
the problem with this code?---End Message---
---BeginMessage---

Hi Shawn
Thanks for answering my query. I have looked at the suggestions:

$xml = simplexml_load_file('file.xml', 'SimpleXMLElement', LIBXML_NOCDATA);

I am/was able to load the file OK and to access the data by iteration.
However, I can't find a way to extract data by attributes. I need something
like $string=element idtype=11 lang=fr label=Description - Etage.
Obviously, that won't work but that's the result I need. How do I get the
data out of one of these elements by specifying its idtype and lang? I've
google for hours on this and for another hour on SimpleXMLElement.

Terry
-- 
View this message in context: 
http://old.nabble.com/simplexml---can-it-do-what-I-need--tp27481222p27486649.html
Sent from the PHP - General mailing list archive at Nabble.com.

---End Message---
---BeginMessage---

TerryA schrieb:

Hi Shawn
Thanks for answering my query. I have looked at the suggestions:

$xml = simplexml_load_file('file.xml', 'SimpleXMLElement', LIBXML_NOCDATA);

I am/was able to load the file OK and to access the data by iteration.
However, I can't find a way to extract data by attributes. I need something
like $string=element idtype=11 lang=fr label=Description - Etage.
Obviously, that won't work but that's the result I need. How do I get the
data out of one of these elements by specifying its idtype and lang? I've
google for hours on this and for another hour on SimpleXMLElement.

Terry

Hi Terry,
look at the PHP.NET documentation. There indicates the use of 
simpleXMLElement structures. If you want to extract elements from this 
object, please read there how this work. By the way, it would be 
interesting to see, how your XML is made. May be is usefull to use 
another class like DOM.


regards

carlos


http://de2.php.net/manual/fr/book.simplexml.php
http://de2.php.net/manual/fr/refs.xml.php
---End Message---
---BeginMessage---
I am developing a website here wherein i need to post a  lot of content.
I am trying to develop a script to post data automatically to the site
the site is designed in drupal
any idea/comment or suggestion 

php-general Digest 8 Feb 2010 04:20:23 -0000 Issue 6579

2010-02-07 Thread php-general-digest-help

php-general Digest 8 Feb 2010 04:20:23 - Issue 6579

Topics (messages 301861 through 301869):

Re: Warning?
301861 by: tedd
301863 by: Shawn McKenzie
301867 by: Jochem Maas
301868 by: tedd

Re: Issue with blocked socket stream
301862 by: Nathan Rixham

Re: Hi list --- justa simple question
301864 by: Al
301865 by: ebhakt
301866 by: shiplu

php selecting multiple stylesheets
301869 by: David Mehler

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---

At 7:02 PM + 2/6/10, Jochem Maas wrote:

Op 2/6/10 4:29 PM, tedd schreef:

 Hi:

 Has anyone encountered this warning?

 Warning: Unknown: Your script possibly relies on a session side-effect
 which existed until PHP 4.2.3. Please be advised that the session
 extension does not consider global variables as a source of data, unless
 register_globals is enabled. You can disable this functionality and this
 warning by setting session.bug_compat_42 or session.bug_compat_warn to
 off, respectively in Unknown on line 0

 I seem to remember this happening before, but I don't remember the
 solution. As I remember, it wasn't really reporting an error, but
 something else. I just don't remember how I dealt with it before.

 I don't know how to set session.bug_compat_warn to off.


doesn't this work?:

?php ini_set('session.bug_compat_warn', 0); ?

otherwise you'll have to set it in php.ini (or a .htaccess file)

IIRC it means your using session_register() .. which is depreciated and
will be dropped in 5.3 ... AFAIK best practices is not to use this function
but instead assing to the $_SESSION superglobal.


Jochem:

Two things:

1. Your solution worked. Setting --

?php ini_set('session.bug_compat_warn', 0); ?

-- worked!!! Thank you.

2. I don't use session_register(). So has to be something else, but I 
don't know what that might be.


Anyone have any ideas?

Daniel?

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com
---End Message---
---BeginMessage---
tedd wrote:
 Hi:
 
 Has anyone encountered this warning?
 
 Warning: Unknown: Your script possibly relies on a session side-effect
 which existed until PHP 4.2.3. Please be advised that the session
 extension does not consider global variables as a source of data, unless
 register_globals is enabled. You can disable this functionality and this
 warning by setting session.bug_compat_42 or session.bug_compat_warn to
 off, respectively in Unknown on line 0
 
 I seem to remember this happening before, but I don't remember the
 solution. As I remember, it wasn't really reporting an error, but
 something else. I just don't remember how I dealt with it before.
 
 I don't know how to set session.bug_compat_warn to off.
 
 Any ideas?
 
 Cheers,
 
 tedd
 
 PS: I'm using php 5.2.10 and register_global is OFF.

This will reproduce the error:

session_start();
$_SESSION['test'] = null;
$test = 1;

It has something to do with using a global var that is the same name as
a session var, but the session var has to be null it seems.


-- 
Thanks!
-Shawn
http://www.spidean.com
---End Message---
---BeginMessage---
Op 2/7/10 3:40 PM, tedd schreef:
 At 7:02 PM + 2/6/10, Jochem Maas wrote:
 Op 2/6/10 4:29 PM, tedd schreef:
  Hi:

  Has anyone encountered this warning?

  Warning: Unknown: Your script possibly relies on a session side-effect
  which existed until PHP 4.2.3. Please be advised that the session
  extension does not consider global variables as a source of data,
 unless
  register_globals is enabled. You can disable this functionality and
 this
  warning by setting session.bug_compat_42 or session.bug_compat_warn to
  off, respectively in Unknown on line 0

  I seem to remember this happening before, but I don't remember the
  solution. As I remember, it wasn't really reporting an error, but
  something else. I just don't remember how I dealt with it before.

  I don't know how to set session.bug_compat_warn to off.

 doesn't this work?:

 ?php ini_set('session.bug_compat_warn', 0); ?

 otherwise you'll have to set it in php.ini (or a .htaccess file)

 IIRC it means your using session_register() .. which is depreciated and
 will be dropped in 5.3 ... AFAIK best practices is not to use this
 function
 but instead assing to the $_SESSION superglobal.
 
 Jochem:
 
 Two things:
 
 1. Your solution worked. Setting --
 
 ?php ini_set('session.bug_compat_warn', 0); ?
 
 -- worked!!! Thank you.

np :)

 
 2. I don't use session_register(). So has to be something else, but I
 don't know what that might be.
 
 Anyone have any ideas?

pretty sure Shawn nailed it.

 
 Daniel?
 
 Cheers,
 
 tedd
 

---End