php-general Digest 15 Jan 2007 16:43:43 -0000 Issue 4571

Topics (messages 247093 through 247103):

Re: Normalized Numbers
        247093 by: Roman Neuhauser

Re: Stored Procedure returns nothing on ROLLBACK
        247094 by: Ligaya A. Turmelle

Re: Stripslashes
        247095 by: Larry Garfield

XML Parsing simpleXML Arrays Question
        247096 by: Richard Luckhurst
        247097 by: Jim Lucas

Re: Unbuffered Query
        247098 by: Németh Zoltán

Re: circular dependency between libraries
        247099 by: Roman Neuhauser

xml_parse() error with   and € etc.. How can i fix this?
        247100 by: Mathijs
        247101 by: Miguel J. Jiménez
        247102 by: Mathijs

memory allocation problems with fgets
        247103 by: Maurizio Molina

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

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


----------------------------------------------------------------------
--- Begin Message ---
# [EMAIL PROTECTED] / 2007-01-14 14:51:30 -0500:
> I tried to install Testilence on my Ubuntu using Gnu make 3.81beta4(my
> skills as a Linux administrator are weaker than my PHP skills) but was
> unsuccessful :(

What problems did you have?

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE.             http://bash.org/?255991

--- End Message ---
--- Begin Message ---
Have you tried it with PDO?  

Respectfully,
Ligaya Turmelle

-----Original Message-----
From: Philip Thompson [mailto:[EMAIL PROTECTED] 
Sent: Saturday, January 13, 2007 1:36 AM
To: php General List
Subject: Re: [PHP] Stored Procedure returns nothing on ROLLBACK

On Jan 11, 2007, at 5:53 PM, Chris wrote:

> Philip Thompson wrote:
>> On Jan 10, 2007, at 6:36 PM, Chris wrote:
>>> Philip Thompson wrote:
>>>> Hi.
>>>> I have been experiencing MSSQL woes lately. I have a stored 
>>>> procedure that I call in PHP using mssql_* functions. In my 
>>>> procedure, I have a transaction that rolls back on failure and 
>>>> commits on success (of course). If it commits, I get the proper 
>>>> return value (int) and the appropriate output parameters.
>>>> However, if it rolls back, I get NOTHING... even if I try to return

>>>> an error code (int) after the ROLLBACK TRANSACTION statement. The 
>>>> output parameter also does not get set upon rollback.
>>>> Is there a way to grab the error even in a rollback? or at least 
>>>> return something besides an empty string/int? I would like to know 
>>>> what error message to provide the user/admin.
>>>> SQL Server 2000, PHP 5.1.6, ntwdblib.dll version 8.00.194
>>>
>>> Does it work outside of php? That is - you run it manually in mssql 
>>> (whatever tools that has) you get the proper codes?
>> Yes, it works perfectly from the server and returns the expected 
>> outcome. It's as though PHP sees the 'rollback' and automatically 
>> assumes that the whole thing failed... so why return a value or 
>> output parameters. Weird, I know. Any other suggestions?
>
> Can you show us the part of the code that deals with the rollback?
>
> If you are issuing a rollback yourself:
>
> $result = mssql_query("rollback transaction");
>
> then you need to handle that yourself because that's treated as a 
> separate query.
>
> If you're not doing that (the transaction is rolling itself back), 
> then I'm out of ideas :)


I'm calling a stored procedure, not running the query from my code.  
So yes, I have a statement in my procedure that has ROLLBACK  
TRANSACTION. It's just odd because I know it works as a script on the  
server, but PHP doesn't recognize it properly, IMHO. I would almost  
be so presumptuous to say that it's a bug. But before I go that  
direction, I wanted to see if anyone had a similar experience. If  
not, I'll go ahead  and think about reporting a bug.

Thanks,
~Phil

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
Copying this back on list where it belongs...

If the apache process on the server is configured to support .htaccess files, 
then there shouldn't be anything special you need to do.  Do you have any 
other htaccess directives in use that could be affecting it?  Remember that 
it's not "htaccess", it's a ".htaccess" file.  Mind the period.


On Sunday 14 January 2007 9:56 pm, Beauford wrote:
> Hi Larry,
>
> I'm sending this off list. I put this in the .htaccess file on the hosting
> server, but still have the same problems. Is there a special way this needs
> to be done?
>
> Thanks
>
> > Thanks
> >
> > > -----Original Message-----
> > > From: Larry Garfield [mailto:[EMAIL PROTECTED]
> > > Sent: January 14, 2007 4:39 PM
> > > To: php-general@lists.php.net
> > > Subject: Re: [PHP] Stripslashes
> > >
> > > On a real web host, they'll let you have a .htaccess file where you
> > > can disable them like so:
> > >
> > > php_value magic_quotes_gpc 0
> > >
> > > (I keep saying "real web host" because I've just recently
> >
> > had to deal
> >
> > > with a few web hosts that a client insisted on that didn't have a
> > > standard configuration and didn't support .htaccess files.
> >
> > I lost 6
> >
> > > hours of my life right before Christmas trying to work around that
> > > fact, and I can't get them back.  If you find yourself in the same
> > > situation, vote with your feet and let such hosts die a
> >
> > horrible and
> >
> > > bankrupt death.)
> > >
> > > On Sunday 14 January 2007 10:46 am, Beauford wrote:
> > > > I just turned  off get_magic_quotes in my PHP.ini, but not
> > >
> > > sure if the
> > >
> > > > hosting company has it on or not once I upload the site.


-- 
Larry Garfield                  AIM: LOLG42
[EMAIL PROTECTED]               ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

--- End Message ---
--- Begin Message ---
Hi List

I have taken the advice of a number of people on the list and am back trying to
write my XML parser using SimpleXML. I am having a problem and I believe the
problem is my lack of understanding of arrays and simpleXML in spite of much
google searching and manual reading. I would appreciate some help.

The piece of XML I am parsing is as follows. I am working with a small section
to see if I can get my head around it.


<?xml version="1.0" encoding="UTF-8"?>
<?ypsilon RNGSchema="fareResponse.rnc" type="compact"?>
<fareResponse cntTarifs="122" offset="0">
  <vcrSummary>
        <vcr minPrice="1667" maxPrice="1667" totalTarifs="1" 
currency="USD">AA</vcr>
        <vcr minPrice="1374" maxPrice="4704" totalTarifs="2" 
currency="USD">PR</vcr>
  </vcrSummary>
</fareResponse>

If I use the following

$file = "test.xml";

        
  $data = simplexml_load_file($file);
        
  foreach ($data->vcrSummary as $vcrSummary)
          {
                var_dump($vcrSummary); 
       }

Then I get

object(SimpleXMLElement)#5 (1) {
  ["vcr"]=>
  array(2) {
    [0]=>
    string(2) "AA"
    [1]=>
    string(2) "PR"
  }
}

Which is pretty much what I would expect as there are 2 vcr tags.

If I then use

$file = "test.xml";

        
        $data = simplexml_load_file($file);

        foreach($data as $vcrSummary)
        {
                $z = $vcrSummary->vcr;
                print "$z \n";
                
        
        }

I get 3 blank lines and then AA which is the first of the two vcr values. The
examples I am looking at suggest I should have gotten both of the vcr values.

Many of the examples I am looking at say to use echo instead of print, eg

echo $vcrSummary->vcr;

and that just gives me AA and not both values that I would expect.

Can anyone point me in the right direction here.

Regards,
Richard Luckhurst                      
Product Development
Exodus Systems - Sydney, Australia.
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
Richard Luckhurst wrote:
Hi List

I have taken the advice of a number of people on the list and am back trying to
write my XML parser using SimpleXML. I am having a problem and I believe the
problem is my lack of understanding of arrays and simpleXML in spite of much
google searching and manual reading. I would appreciate some help.

The piece of XML I am parsing is as follows. I am working with a small section
to see if I can get my head around it.


<?xml version="1.0" encoding="UTF-8"?>
<?ypsilon RNGSchema="fareResponse.rnc" type="compact"?>
<fareResponse cntTarifs="122" offset="0">
  <vcrSummary>
        <vcr minPrice="1667" maxPrice="1667" totalTarifs="1" 
currency="USD">AA</vcr>
        <vcr minPrice="1374" maxPrice="4704" totalTarifs="2" 
currency="USD">PR</vcr>
  </vcrSummary>
</fareResponse>

If I use the following

$file = "test.xml";

$data = simplexml_load_file($file);
Just to confirm your data structure, do a var_dump($data) right here and see what the output is
  foreach ($data->vcrSummary as $vcrSummary)
          {
var_dump($vcrSummary); }

Then I get

object(SimpleXMLElement)#5 (1) {
  ["vcr"]=>
  array(2) {
    [0]=>
    string(2) "AA"
    [1]=>
    string(2) "PR"
  }
}

Which is pretty much what I would expect as there are 2 vcr tags.

If I then use

$file = "test.xml";

$data = simplexml_load_file($file);

right here you, at least from the example above, you need to be using $data->vcrSummary as the first parameter of the foreach loop
        foreach($data as $vcrSummary)
        {
then here I would be using another foreach loop, because the $vcrSummary->vcr is an array with two indexes 0 and 1... So

foreach ( $vcrSummary->vcr AS $v ) {
   echo "{$v}\n";
}
                $z = $vcrSummary->vcr;
                print "$z \n";
}

I get 3 blank lines and then AA which is the first of the two vcr values. The
examples I am looking at suggest I should have gotten both of the vcr values.

Many of the examples I am looking at say to use echo instead of print, eg

echo $vcrSummary->vcr;
if done correctly, this should echo "Array" and maybe a warning.   :(

Jim Lucas
and that just gives me AA and not both values that I would expect.

Can anyone point me in the right direction here.

Regards,
Richard Luckhurst Product Development
Exodus Systems - Sydney, Australia.
[EMAIL PROTECTED]


--- End Message ---
--- Begin Message ---
I think mysql_data_seek throws this warning also if there is no data in
the result object at all, so I would check the result before positioning

greets
Zoltán Németh

2007. 01. 12, péntek keltezéssel 23.30-kor Richard Lynch ezt írta:
> I have this process that dumps out database records to static HTML pages.
> 
> The basic algorithm goes like:
> 
> //Set any un-parented item (a root in the thread) to be its own parent:
> update entry set original_id = entry_id where original_id is null
> 
> //collect any "dirty" entries (changed in db, need to re-publish)
> $dirty = select entry_id from entry where dirty = 1
> 
> while (list($entry_id) = mysql_fetch_row($dirty)){
>   //find the whole thread:
>   $followups = select entry_id, X, Y from entry where original_id =
> $dirty_id
>   //there is an ORDER BY which is not relevant
> 
>   //get some thread metadata from the first row's X field
>   list($junk, $X) = mysql_fetch_row($followups);
>   //$X is the same for all rows...
>   echo "<h1>$X</h1>\n";
> 
>   //reset to row 0
>   mysql_data_seek($followups, 0);
>   while (list($entry_id, $X, $Y) = mysql_fetch_row($followups)){
>     echo "<p>$Y</p>\n";
>   }
> }
> 
> So, how come *SOMETIMES*, seemingly at random, I get:
> 
> Warning: mysql_data_seek(): Offset 0 is invalid for MySQL result index
> 116 (or the
> query data is unbuffered) in
> /www/acousticdemo.com/web/complaints/publish.cron on
> line 26
> 
> Line 26 is, obviously, the mysql_data_seek call above...
> 
> I do not *THINK* there is any other process anywhere deleting rows
> from the table -- it should be an ever-growing table...
> 
> So is the query data being unbuffered out from under me due to some
> my.cnf setting?...
> 
> Or am I just plain wrong, and *something* is deleting from the entry
> table?
> 
> I Googled for the error message, and found about a 26,000 web sites
> that are exhibiting this error, rather than the folks discussing this
> error. :-v
> 
> The few I was able to weed out were obvious logic errors, which I
> don't think I have.
> 
> I've read the mysql_unbuffered_query on php.net and think I understand
> it in respect to mysql_query et al.
> 
> I guess I'm looking for reassurance that it's definitely my mistake
> somewhere in the mess I've made, and that I'm looking for a delete
> query, and it's not a subtle bug or feature I'm failing to understand.
> 
> :-)
> 
> -- 
> Some people have a "gift" link here.
> Know what I want?
> I want you to buy a CD from some starving artist.
> http://cdbaby.com/browse/from/lynch
> Yeah, I get a buck. So?
> 

--- End Message ---
--- Begin Message ---
# [EMAIL PROTECTED] / 2007-01-14 20:47:02 +0100:
> Roman Neuhauser wrote:
> > I have a circular dependency, and am looking for thoughts on breaking
> > the cycle without (much) redundancy or hard to automate procedures.
> > 
> > I'm developing two programs, Testilence, a unit testing library, and
> > Amock (library for mock object generation, but that's irrelevant in this
> > discussion); both programs have unit tests based on Testilence, but
> > Amock itself should not depend on Testilence, and neither should contain
> > (or depend on) nontested code.
> > 
> > Testilence contains some utility classes I'd like to use in Amock (or
> > indeed, anywhere).  I could "fork" them, but would like to avoid this
> > if at all possible.  I think I can't pull them out into a separate
> > library for both Amock and Testilence to depend on because that would
> > create a dependency loop between the utility and Testilence since I'd
> > like to keep using Testilence for the utility's unit tests.
> 
> isn't there a circular dependency anyway? given that you unit test
> Testilence with Testilence?
 
I should've stressed that I'm coming from the packaging side (think RPMs
or such).  You can run Testilence's test suite without having Testilence
installed (both are in the same tarball), so there's no cycle.

The goal is to make a successful run of the test suite a prerequisite of
the utility installation...  Think RPM or similar: if X.rpm depends on
Y.rpm in runtime, you cannot make Y's installation depend on execution
of commands from X.

> if these utility classes are utility classes I wonder whether it's not better
> if they have no external dependencies?
 
That depends on relative merits in individual situations, I cannot
answer this question as is either way.

> whilst reading about Testilence I remember coming across a mention of runkit

runkit is mention because I'm considering its use for better test
isolation, I haven't thought of using it for "normal" code.

> ... whilst I wonder whether using runkit for anything other than experimental
> stuff, could runkit not offer a solution (e.g. renaming the class dependent on
> the context of it's usage)? probably not, right?

How would this work?

> > Both Amock and Testilence are versioned using Subversion, so I could
> > leave the classes in Testilence and use svn:externals to put them in
> > Amock too.  That would lead to name clashes if both programs were used
> > together, and that is a showstopper.
> 
> given that they are the same code would conditional loading of the utlity
> classes not work? i.e. only load if they don't already exist
 
That seems quite fragile, but I admit I haven't thought it through.

> this could be augemented with the use of a [number of] Interfaces - if
> the class already exists and doesn't implement the required interfaces
> then your code bails out.

I'm not concerned about the user who's *attempting* to shoot himself in
the foot, I'm worrying about my code shooting an unsuspecting user in
the butt.

So far I'm leaning towards pulling the utility out from Testilence,
sacrificing the ability to unit test the library without jumping through
hoops.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE.             http://bash.org/?255991

--- End Message ---
--- Begin Message ---
Hello there,

When i want use parse_xml() and i have entities like &nbsp; in it, it gives me a entity error.

This because the parser doesn't know the &nbsp; entity.

Now i saw on the bugs site of php a way to solve this, by using xml_set_external_entity_ref_handler() with http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent.
See here: http://bugs.php.net/bug.php?id=15092#c27617

But, it seems my knowledge of PHP isn't that good enough to understand what i have to do to get this to work.

Can someone please help me to get this to work?

Thx in advanced.

--- End Message ---
--- Begin Message ---
El Mon, 15 Jan 2007 12:42:58 +0100
Mathijs <[EMAIL PROTECTED]> escribió:

> Hello there,
> 
> When i want use parse_xml() and i have entities like &nbsp; in it, it 
> gives me a entity error.
> 
> This because the parser doesn't know the &nbsp; entity.
> 
> Now i saw on the bugs site of php a way to solve this, by using 
> xml_set_external_entity_ref_handler() with 
> http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent.
> See here: http://bugs.php.net/bug.php?id=15092#c27617
> 
> But, it seems my knowledge of PHP isn't that good enough to
> understand what i have to do to get this to work.
> 
> Can someone please help me to get this to work?
> 
> Thx in advanced.
> 

Try to use number codes, ie. &#160; instead of &nbsp; and &#164;
instead of &euro;


-- 
Miguel J. Jiménez
Área de Internet/XSL
[EMAIL PROTECTED]

----------------------------------------------------

ISOTROL
Edificio BLUENET, Avda. Isaac Newton nº3, 4ª planta.
Parque Tecnológico Cartuja '93, 41092 Sevilla.
Teléfono: 955 036 800 - Fax: 955 036 849
http://www.isotrol.com

"Siempre intento salvar una vida al día. Normalmente es la mía"
(John Crichton, FARSCAPE 1x07)

--- End Message ---
--- Begin Message ---
Miguel J. Jiménez wrote:
El Mon, 15 Jan 2007 12:42:58 +0100
Mathijs <[EMAIL PROTECTED]> escribió:

Hello there,

When i want use parse_xml() and i have entities like &nbsp; in it, it gives me a entity error.

This because the parser doesn't know the &nbsp; entity.

Now i saw on the bugs site of php a way to solve this, by using xml_set_external_entity_ref_handler() with http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent.
See here: http://bugs.php.net/bug.php?id=15092#c27617

But, it seems my knowledge of PHP isn't that good enough to
understand what i have to do to get this to work.

Can someone please help me to get this to work?

Thx in advanced.


Try to use number codes, ie. &#160; instead of &nbsp; and &#164;
instead of &euro;



That i know, but how can i have this automated.
Because the input is out of my hands.
If someone puts in the &nbsp; or &euro; i have to convert this.

This can be fixed by adding the the xhtml-lat1.ent some way.
Would be nice if i can do this by the xml_* way or something.

--- End Message ---
--- Begin Message ---
Hi,
I have a script parsing the lines of a (rather large) file:
 
while (!feof($outPluginfh)) {
    $outPlugin = fgets ($outPluginfh,1024);
# process $outPlugin here...
....
    }

Now, with large files I was running into an memory allocation error
(after 16MB of allocation..).
It looks that php is allocating space for each fgets call, an not
releasing it, in spite of the return value being always  assigned to the
same variable.
I red in other posts that for removing this 16MB limit I can simply put
the statement
ini_set("memory_limit",-1);
at the beginning, and in fact this line does the job.
However, I'm not happy because  I lost control of how much memeory php
is allcating on my system, and I fear that with multiple users
triggering this script I'll sooner or later run into (worse) problems.
Is there any other more controllable way to do?
Thanks,
Maurizio Molina

--- End Message ---

Reply via email to