php-general Digest 4 May 2005 10:50:28 -0000 Issue 3434

Topics (messages 214384 through 214391):

Re: php newbie question with xml files
        214384 by: disguised.jedi.gmail.com
        214385 by: Jason Barnett

Downloads stop short
        214386 by: Mike

PHP5 DOM & compressed xml
        214387 by: Jared Williams

Re: forms
        214388 by: Lisa A

if then else
        214389 by: Anasta

Re: only allowing php_flag register_globals off
        214390 by: Karin van den Berg

is_numeric
        214391 by: pete M

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:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
> I have an xml document storing some data I need. What I want to do is this:
> 1. Scan to the end of the file.
> 2. Find the closing tag.
> 3. Insert a new entry in before the closing tag.

There are specific classes and functions in the PHP core that can help
you do just this.

> I've tried:
> 1. Creating new files and renaming them to be the original.
> 2. Writing the file to a dummy file and insert my lines part way through
> then finish the last tag.

I don't think this is the right approach to take.  Maybe using the DOM
and/or the XML Parser built-in to php would help you.

> My problem is I'm looking for a </endtag> and it comes up as endtag. Is
> there anyway to force PHP to read the .xml file as a text file so it wont
> strip off the xml tag information?
> 
> I've used fopen with fgets and fwrite, and file with fwrite

Again, this isn't the approach to take.  There are built-in functions
for this sort of thing, as well as classes on PEAR that will help you.
 Try google!

Read through all of this and decide which approach you want to take
before you start anything...

If you use Windows or compile PHP as an Apache module in Linux, you're
all set with the XML Parser.  If not, you'll need to get the library
according to the directions in the manual.

http://www.php.net/xml

Read everything in that thoroughly, and understand it before you
continue with this approach.  Copy and play with the examples to see
how it all works.  If you'd rather handle things in an environment
designed to create and manipulate XML dynamically, rather than just
read and insert raw strings, keep reading.

You can get the DOM XML working easily in Windows, and even easier in
a GNOME environment on a linux box.  The manual has excellent
instructions.

http://www.php.net/domxml

This extension is Object-Oriented (OO), and if you don't know what
that is, you better read up on it before you try this out.  If you do,
and have an OK understanding of how OO works in PHP, then read on!  If
not, read the article....

http://www.php.net/oop

Now, understand that DOM XML is very particular about the syntax and
such in an XML file.  The file MUST start with the XML declaration
(without quotes) "<?xml version=1.0>" in order for DOM to try and use
it.

Use the functions to read right through it all.  You'll find that this
is probably exactly what you need!

I'd use DOM XML personally.  I included the other in case you didn't
want to have to install everything.

Have fun, and good luck with PHP!

-- 
[EMAIL PROTECTED]

PHP rocks!
"Knowledge is Power.  Power Corrupts.  Go to school, become evil"

Disclaimer: Any disclaimer attached to this message may be ignored. 
However, I must say that the ENTIRE contents of this message are
subject to other's criticism, corrections, and speculations.

This message is Certified Virus Free

--- End Message ---
--- Begin Message ---
PHP5:

http://php.net/manual/en/ref.dom.php
--- End Message ---
--- Begin Message ---


I upgraded to PHP 5.0.4 and now all my downloads cut off at 1.9 MB

Is this a setting I missed somewhere?


+--------------------------------------------+
Mike Yrabedra 
[EMAIL PROTECTED] 
Your Mac Intelligence Resource
+--------------------------------------------+
W: http://www.macagent.com/

--- End Message ---
--- Begin Message ---
Hi,
        Has anyone got the DOM extension to load compressed XML transparently?

        libxml2 apparently has this feature, but it appears not present in PHP 
build.

Jared

--- End Message ---
--- Begin Message ---
Thanks for the info, but do I create the form in front page then?  Where 
does this script go?  Do I save the php you sent as a results page?
thanks,
Lisa A
"Jason Barnett" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Lisa A wrote:
>> Does anyone know of a good easy php script or Form that we can use with 
>> Front Page.
>> We need a form to get results, that actually sends the results in a 
>> format that is easy to read.
>> Not all run together with no spaces, etc. like the Front Page forms.
>> Thanks,
>> Lisa A
>
> <?php
>
> /** File Action.php
> *   This page should be the action for your form page
> */
>
> /** Formatting */
> echo '<pre>';
>
> /** Print out form vars */
> print_r($_GET);
> print_r($_POST);
>
> /** Not 100% accurate, but an alternative if you're lazy */
> print_r($_REQUEST);
>
> /** Just for completeness, the closing tag */
> echo '</pre>';
>
> ?> 

--- End Message ---
--- Begin Message ---
Can anyone help with a statement, ive tried but it never works.
I need to show a value if it is set to a specific value  ie:

At the moment If a user is logs in a record is updated from 'away' to
'online'---so i want an echo statement to show a value from another table if
they are set to online or else they show another value.
(2 seperate tables).

--- End Message ---
--- Begin Message ---
Richard Lynch wrote:


Are they unwilling to change it for a paying account, or just the trial one?

Big difference. :-)
Well it's not a standard trail account. One of the owners offered me to try it for a month to see if it suited me. My domain is moved to them and everything.. so it's probably treated as any other account. And it's not exactly budget hosting either......


.htaccess off also gives a performance boost they might not be willing to forego, even if it were possible.

.htaccess is not off, just the php_flag/php_value

--- End Message ---
--- Begin Message --- not a php expert but have filed this bug report re validating is_numeric('3e0');
http://bugs.php.net/bug.php?id=32943


Now tried

  function isnumeric($n) {
   if (ereg("^[0-9]{1,50}.?[0-9]{0,50}$", $n)) {
     return true;
   } else {
     return false;
   }
  }

and that doent seem to work either..

any ideas.. need to validate anything without 0-9 and a dot within

tia

Pete
--- End Message ---

Reply via email to