php-windows Digest 10 May 2002 07:18:14 -0000 Issue 1137

Topics (messages 13660 through 13679):

Re: Simple function question
        13660 by: Scott Carr
        13661 by: Bradley Miller
        13665 by: Scott Hurring

Re: register_globals and php 4.2
        13662 by: brother
        13672 by: Afan Pasalic
        13673 by: Shrock, Court
        13674 by: Shrock, Court
        13675 by: Robin Bolton
        13677 by: Steve Yates
        13679 by: brother

flushing output to the browser whilst  the script does something useful
        13663 by: Mr. Adam ALLEN.
        13664 by: Olivier Hubert
        13668 by: Scott Hurring
        13678 by: Steve Yates

Re: how do i display errors
        13666 by: Scott Hurring

Re: how do i split text on multi linez .... ????
        13667 by: Scott Hurring

Data output
        13669 by: Matt Babineau
        13670 by: Piotr Pluciennik
        13671 by: Olivier Hubert

XML parsing
        13676 by: Carl Lerche

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 ---
Use $GLOBALS['var1']

That will get the variable from the correct scope.
-- 
Scott Carr
OpenOffice.org
Whiteboard-Doc Maintainer
http://whiteboard.openoffice.org/doc/


Quoting Matt Babineau <[EMAIL PROTECTED]>:

> Ok, I just read a section in a book about functions. In my cost I have
> some variables set:
>  
> $var1 = "1";
>  
> And I have a function I wrote that needs to utilize that variable.
>  
> function runvar()    {
>     query database looking for $var1;
>     }
>  
> I get horrible errors though. In the book it talked about the local
> fuciton scope not being able to communicate with the global scope. How
> can I pass $var1 into the function so it can be used?
>  
> Matt Babineau
> Freelance Internet Developer
> -----------------------------------------
> e:  <mailto:[EMAIL PROTECTED]>
> [EMAIL PROTECTED]
> p: 603.943.4237
> w:  <http://www.illuminatistudios.com/> http://www.illuminatistudios.com
>  
> 


-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/
--- End Message ---
--- Begin Message ---
At 03:02 PM 5/9/02 -0400, Matt Babineau wrote:
>Ok, I just read a section in a book about functions. In my cost I have
>some variables set:
> 
>$var1 = "1";
> 
>And I have a function I wrote that needs to utilize that variable.
> 
>function runvar()    {
>    query database looking for $var1;
>    }


function runvar()    {
global $var1;
    query database looking for $var1;
    }
--- End Message ---
--- Begin Message ---
// Setup the function like this
function runvar ($var1) {
...
}

// Call it like this
runvar($var1);

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -----Original Message-----
> From: Matt Babineau [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 09, 2002 3:02 PM
> To: 'Php-Win (E-mail)'
> Subject: [PHP-WIN] Simple function question
> 
> 
> Ok, I just read a section in a book about functions. In my cost I have
> some variables set:
>  
> $var1 = "1";
>  
> And I have a function I wrote that needs to utilize that variable.
>  
> function runvar()    {
>     query database looking for $var1;
>     }
>  
> I get horrible errors though. In the book it talked about the local
> fuciton scope not being able to communicate with the global scope. How
> can I pass $var1 into the function so it can be used?
 
--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Shrock, Court [mailto:[EMAIL PROTECTED]] 
> 
> Replace all references of "$pagetype" with 
> "$_GET['pagetype']" (without the
> doube-quotes, of course) or have the line "$pagetype = 
> $_GET['pagetype']" at
> the beginning of your file.  Repeat this same idea with your 
> other variables
> and you should be okay.

I had tested that but forgot the casesensitive on variablenames, have I ate
any bad stuff that had my brain to blow up?? 

Thanks Court!

/brother
--- End Message ---
--- Begin Message ---
I have the same problem but putting $var_name = $_GET['var_name'] didn't solve the 
problem. I put it on the top of the page (e.g. line no. 2) and I'm getting error:
PHP Warning: Undefined index: var_name in F:\bhdanas.com\index.php on line 2

Any idea?


Afan


----- Original Message ----- 
From: Shrock, Court 
To: brother ; '[EMAIL PROTECTED]' 
Sent: Thursday, May 09, 2002 1:07 PM
Subject: RE: [PHP-WIN] register_globals and php 4.2


Replace all references of "$pagetype" with "$_GET['pagetype']" (without the
doube-quotes, of course) or have the line "$pagetype = $_GET['pagetype']" at
the beginning of your file.  Repeat this same idea with your other variables
and you should be okay.

> -----Original Message-----
> From: brother [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 09, 2002 5:11 AM
> To: '[EMAIL PROTECTED]'
> Subject: [PHP-WIN] register_globals and php 4.2
> 
> 
> I'm trying to rewrite my code so it will be useful under PHP 4.2.
> the links at my site are in this format
> index.php?pagetype=newsarchive&id=15&read=1 this will make 
> php to look fpr
> the file /newsarchive/data.php and use the $id var to get the correct
> newsline from the databse, however, when the register_globals 
> is set to off
> I can't use this and I cann't figre out how to do it, HELP!
> 
> the index.php starts with the code:
> if (!isset($pagetype)) {
>      $pagetype = "news";
> }
> 
> so all links displays the news page and that's not my goal =)
> 
> /brother
> 
> -- 
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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

--- End Message ---
--- Begin Message ---
You will get that error because you did not reach the page via the url
"index.php?var_name=tada", therefore, "var_name" is not defined in the _GET
superglobal array so you get a warning because of your error_reporting
setting.  The warning that was printed is actually a notice configured
within your php.ini-- error_reporting = ALL & ~NOTICE -- is what it should
be.

> -----Original Message-----
> From: Afan Pasalic [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 09, 2002 4:27 PM
> To: [EMAIL PROTECTED]
> Subject: Fw: [PHP-WIN] register_globals and php 4.2
> 
> 
> I have the same problem but putting $var_name = 
> $_GET['var_name'] didn't solve the problem. I put it on the 
> top of the page (e.g. line no. 2) and I'm getting error:
> PHP Warning: Undefined index: var_name in 
> F:\bhdanas.com\index.php on line 2
> 
> Any idea?
> 
> 
> Afan
> 
> 
> ----- Original Message ----- 
> From: Shrock, Court 
> To: brother ; '[EMAIL PROTECTED]' 
> Sent: Thursday, May 09, 2002 1:07 PM
> Subject: RE: [PHP-WIN] register_globals and php 4.2
> 
> 
> Replace all references of "$pagetype" with 
> "$_GET['pagetype']" (without the
> doube-quotes, of course) or have the line "$pagetype = 
> $_GET['pagetype']" at
> the beginning of your file.  Repeat this same idea with your 
> other variables
> and you should be okay.
> 
> > -----Original Message-----
> > From: brother [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, May 09, 2002 5:11 AM
> > To: '[EMAIL PROTECTED]'
> > Subject: [PHP-WIN] register_globals and php 4.2
> > 
> > 
> > I'm trying to rewrite my code so it will be useful under PHP 4.2.
> > the links at my site are in this format
> > index.php?pagetype=newsarchive&id=15&read=1 this will make 
> > php to look fpr
> > the file /newsarchive/data.php and use the $id var to get 
> the correct
> > newsline from the databse, however, when the register_globals 
> > is set to off
> > I can't use this and I cann't figre out how to do it, HELP!
> > 
> > the index.php starts with the code:
> > if (!isset($pagetype)) {
> >      $pagetype = "news";
> > }
> > 
> > so all links displays the news page and that's not my goal =)
> > 
> > /brother
> > 
> > -- 
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> > 
> 
> -- 
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
--- End Message ---
--- Begin Message ---
Oops.....replace the "ALL" with "E_ALL" and "NOTICE" with "E_NOTICE"

> -----Original Message-----
> From: Shrock, Court [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 09, 2002 4:51 PM
> To: Afan Pasalic; [EMAIL PROTECTED]
> Subject: RE: [PHP-WIN] register_globals and php 4.2
> 
> 
> You will get that error because you did not reach the page via the url
> "index.php?var_name=tada", therefore, "var_name" is not 
> defined in the _GET
> superglobal array so you get a warning because of your error_reporting
> setting.  The warning that was printed is actually a notice configured
> within your php.ini-- error_reporting = ALL & ~NOTICE -- is 
> what it should
> be.
> 
> > -----Original Message-----
> > From: Afan Pasalic [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, May 09, 2002 4:27 PM
> > To: [EMAIL PROTECTED]
> > Subject: Fw: [PHP-WIN] register_globals and php 4.2
> > 
> > 
> > I have the same problem but putting $var_name = 
> > $_GET['var_name'] didn't solve the problem. I put it on the 
> > top of the page (e.g. line no. 2) and I'm getting error:
> > PHP Warning: Undefined index: var_name in 
> > F:\bhdanas.com\index.php on line 2
> > 
> > Any idea?
> > 
> > 
> > Afan
> > 
> > 
> > ----- Original Message ----- 
> > From: Shrock, Court 
> > To: brother ; '[EMAIL PROTECTED]' 
> > Sent: Thursday, May 09, 2002 1:07 PM
> > Subject: RE: [PHP-WIN] register_globals and php 4.2
> > 
> > 
> > Replace all references of "$pagetype" with 
> > "$_GET['pagetype']" (without the
> > doube-quotes, of course) or have the line "$pagetype = 
> > $_GET['pagetype']" at
> > the beginning of your file.  Repeat this same idea with your 
> > other variables
> > and you should be okay.
> > 
> > > -----Original Message-----
> > > From: brother [mailto:[EMAIL PROTECTED]]
> > > Sent: Thursday, May 09, 2002 5:11 AM
> > > To: '[EMAIL PROTECTED]'
> > > Subject: [PHP-WIN] register_globals and php 4.2
> > > 
> > > 
> > > I'm trying to rewrite my code so it will be useful under PHP 4.2.
> > > the links at my site are in this format
> > > index.php?pagetype=newsarchive&id=15&read=1 this will make 
> > > php to look fpr
> > > the file /newsarchive/data.php and use the $id var to get 
> > the correct
> > > newsline from the databse, however, when the register_globals 
> > > is set to off
> > > I can't use this and I cann't figre out how to do it, HELP!
> > > 
> > > the index.php starts with the code:
> > > if (!isset($pagetype)) {
> > >      $pagetype = "news";
> > > }
> > > 
> > > so all links displays the news page and that's not my goal =)
> > > 
> > > /brother
> > > 
> > > -- 
> > > PHP Windows Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > > 
> > 
> > -- 
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> > 
> > 
> 
> -- 
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
--- End Message ---
--- Begin Message ---
Or, you can simply use:
@$var_name = $_GET['var_name']

to suppress error messages.

-----Original Message-----
From: Shrock, Court [mailto:[EMAIL PROTECTED]] 
Sent: May 9, 2002 17:51
To: Afan Pasalic; [EMAIL PROTECTED]
Subject: RE: [PHP-WIN] register_globals and php 4.2

You will get that error because you did not reach the page via the url
"index.php?var_name=tada", therefore, "var_name" is not defined in the
_GET
superglobal array so you get a warning because of your error_reporting
setting.  The warning that was printed is actually a notice configured
within your php.ini-- error_reporting = ALL & ~NOTICE -- is what it
should
be.

> -----Original Message-----
> From: Afan Pasalic [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 09, 2002 4:27 PM
> To: [EMAIL PROTECTED]
> Subject: Fw: [PHP-WIN] register_globals and php 4.2
> 
> 
> I have the same problem but putting $var_name = 
> $_GET['var_name'] didn't solve the problem. I put it on the 
> top of the page (e.g. line no. 2) and I'm getting error:
> PHP Warning: Undefined index: var_name in 
> F:\bhdanas.com\index.php on line 2
> 
> Any idea?
> 
> 
> Afan
> 
> 
> ----- Original Message ----- 
> From: Shrock, Court 
> To: brother ; '[EMAIL PROTECTED]' 
> Sent: Thursday, May 09, 2002 1:07 PM
> Subject: RE: [PHP-WIN] register_globals and php 4.2
> 
> 
> Replace all references of "$pagetype" with 
> "$_GET['pagetype']" (without the
> doube-quotes, of course) or have the line "$pagetype = 
> $_GET['pagetype']" at
> the beginning of your file.  Repeat this same idea with your 
> other variables
> and you should be okay.
> 
> > -----Original Message-----
> > From: brother [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, May 09, 2002 5:11 AM
> > To: '[EMAIL PROTECTED]'
> > Subject: [PHP-WIN] register_globals and php 4.2
> > 
> > 
> > I'm trying to rewrite my code so it will be useful under PHP 4.2.
> > the links at my site are in this format
> > index.php?pagetype=newsarchive&id=15&read=1 this will make 
> > php to look fpr
> > the file /newsarchive/data.php and use the $id var to get 
> the correct
> > newsline from the databse, however, when the register_globals 
> > is set to off
> > I can't use this and I cann't figre out how to do it, HELP!
> > 
> > the index.php starts with the code:
> > if (!isset($pagetype)) {
> >      $pagetype = "news";
> > }
> > 
> > so all links displays the news page and that's not my goal =)
> > 
> > /brother
> > 
> > -- 
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> > 
> 
> -- 
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

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


--- End Message ---
--- Begin Message ---
"Court Shrock" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]...
> Replace all references of "$pagetype" with "$_GET['pagetype']" (without
the
> doube-quotes, of course) or have the line "$pagetype = $_GET['pagetype']"
at
> the beginning of your file.  Repeat this same idea with your other
variables

    Or to get them all at once use extract($HTTP_GET_VARS).

 - Steve Yates
 - I didn't fight my way to the top of the food chain to be a vegetarian.

/ Taglines by Taglinator - www.srtware.com /




--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Afan Pasalic [mailto:[EMAIL PROTECTED]] 
> 
> I have the same problem but putting $var_name = 
> $_GET['var_name'] didn't solve the problem. I put it on the 
> top of the page (e.g. line no. 2) and I'm getting error:
> PHP Warning: Undefined index: var_name in 
> F:\bhdanas.com\index.php on line 2
> 
> Any idea?
> 
> 
> Afan

if (!isset($_GET['var_name'])) {
   $var_name = "default value";
} else {
   $var_name = $_GET['var_name'];
}

/brother
--- End Message ---
--- Begin Message ---
Wasn't sure on what the best way of describing it in a few words..

I have a few php scripts which outputs a good page worth of html,
then there is a long delay while something useful is done by the script.

Currently, html only gets displayed by the browser once the complete
script has finished. What I'm looking to do, is flush the HTML out at
key points. (i.e. before I start the processing, so users actually know
somethings happening -rather thana appearing as if the connection is
timing-out).

How would this be done in PHP?


Regards,
Adam
--- End Message ---
--- Begin Message ---
You might want to look at the flush() function which seem to do exactly 
what you need.

http://www.php.net/manual/en/function.flush.php

However please note that your web server might still buffer the output. You 
would then have to look at the server level to solve your problem.

Hope this helps,

Olivier Hubert

At 20:29 2002-05-09 +0100, Mr. Adam ALLEN. wrote:
>Wasn't sure on what the best way of describing it in a few words..
>
>I have a few php scripts which outputs a good page worth of html,
>then there is a long delay while something useful is done by the script.
>
>Currently, html only gets displayed by the browser once the complete
>script has finished. What I'm looking to do, is flush the HTML out at
>key points. (i.e. before I start the processing, so users actually know
>somethings happening -rather thana appearing as if the connection is
>timing-out).
>
>How would this be done in PHP?
>
>
>Regards,
>Adam
>
>--
>PHP Windows Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
If this doesn't work for you, try printing out all
your HTML, spawn the "long" proc. into the background
and then exit.

Then, on the HTML you outputted, use a META REFRESH or
Javascript refresh (or just putting a link at the bottom
for the user to click on), so that the user can then
see the output of the long process.

What is the long proc. doing anyway?

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -----Original Message-----
> From: Olivier Hubert [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 09, 2002 3:40 PM
> To: Mr. Adam ALLEN.; [EMAIL PROTECTED]
> Subject: Re: [PHP-WIN] flushing output to the browser whilst 
> the script
> does something useful
> 
> 
> You might want to look at the flush() function which seem to 
> do exactly 
> what you need.
> 
> http://www.php.net/manual/en/function.flush.php
> 
> However please note that your web server might still buffer 
> the output. You 
> would then have to look at the server level to solve your problem.
> 
> Hope this helps,
> 
> Olivier Hubert
> 
> At 20:29 2002-05-09 +0100, Mr. Adam ALLEN. wrote:
> >Wasn't sure on what the best way of describing it in a few words..
> >
> >I have a few php scripts which outputs a good page worth of html,
> >then there is a long delay while something useful is done by 
> the script.
> >
> >Currently, html only gets displayed by the browser once the complete
> >script has finished. What I'm looking to do, is flush the HTML out at
> >key points. (i.e. before I start the processing, so users 
> actually know
> >somethings happening -rather thana appearing as if the connection is
> >timing-out).
> >
> >How would this be done in PHP?
> >
> >
> >Regards,
> >Adam
> >
> >--
> >PHP Windows Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> -- 
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
--- End Message ---
--- Begin Message ---
"Mr. Adam Allen." <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Currently, html only gets displayed by the browser once the complete
> script has finished. What I'm looking to do, is flush the HTML out

    How about flush() ?  :)

http://www.php.net/manual/en/function.flush.php

 - Steve Yates
 - I'm sorry, were the voices in my head bothering you?

/ Taglines by Taglinator - www.srtware.com /




--- End Message ---
--- Begin Message ---
Look for trace_errors in php.ini and it'll tell you about itself.

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -----Original Message-----
> From: Mauricio [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, May 08, 2002 5:03 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-WIN] how do i display errors
> 
> 
> Hi for all.
> I configured my php.ini using:
> 
> display_errors = On
> log_erros = On
> 
> but, my browser don't show erros yet.
> 
> Could Anyone help me?
> 
> Thanks in advance.
> 
> 
> 
> -- 
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
--- End Message ---
--- Begin Message ---
Yes.

If you're outputting to a browser, the browser ignores 
linefeeds. you *need* some kind of HTML to split up lines.

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -----Original Message-----
> From: Mike Flynn [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 09, 2002 1:55 PM
> To: toby z; php hlp list; [EMAIL PROTECTED]
> Subject: Re: [PHP-WIN] how do i split text on multi linez .... ????
> 
> 
> Better yet, use the nl2br function to convert newline 
> characters (\n) into 
> <br> tags.. see:
> http://www.php.net/manual/en/function.nl2br.php
> 
> At 05:56 PM 5/9/02 +0100, toby z wrote:
> >guyz ... im stuck .... yet again .....
> >
> >this time it is .....
> >
> >im taking input from user .... a whole article and its
> >summary ....
> >its writing to the file fine ....
> >but it gives out the summary and the article in a
> >single line .....
> >starts from the first word and sees it thru the last
> >... ON THE SAME LINE .......
> >
> >my code iz  ....
> >
> >
> ><?php
> >
> >
> >$fp=fopen("c:\\name.txt", "wb");
> >fwrite($fp, "$lastName,$firstName ");
> >
> >fwrite($fp, "\r\n");
> >fwrite($fp, "\r\n");
> >
> >
> >fwrite($fp, "$lang ");
> >fwrite($fp, "\r\n");
> >fwrite($fp, "\r\n");
> >
> >
> >fwrite($fp, "$cat ");
> >fwrite($fp, "\r\n");
> >fwrite($fp, "\r\n");
> >
> >
> >fwrite($fp, "$title ");
> >fwrite($fp, "\r\n");
> >fwrite($fp, "\r\n");
> >
> >$string = fwrite($fp, "$summary ");
> >
> >$array = preg_split( "/[ \t]+/", $string );
> >
> >$myarray = explode("\r\n", "$string");
> >
> >
> >fwrite($fp, "\r\n");
> >fwrite($fp, "\r\n");
> >
> >
> >fwrite($fp, "$body ");
> >fwrite($fp, "\r\n");
> >fwrite($fp, "\r\n");
> >
> >fclose($fp);
> >
> >?>
> >
> >
> >
> >so .... i have tried it with preg_split, explode ....
> >togather az well az seperately .....
> >but ...... (N) .....
> >
> >vat can i do to fix it ?????
> >
> >thnx a million .......
> >
> >toby ....
> >
> >__________________________________________________
> >Do You Yahoo!?
> >Yahoo! Shopping - Mother's Day is May 12th!
> >http://shopping.yahoo.com
> >
> >--
> >PHP Windows Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> -- Mike Flynn --
> mike @ mikeflynn . net
> home => work => home => shop => home [adbusters]
> 
> 
> -- 
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
--- End Message ---
--- Begin Message ---
After I output data from a query with a for() loop, It seems like I
cannot reuse the array from the query any more. Do I have to requery the
database for the same info so that I can add up the database columns?
 
       <?PHP 
       
       $bgcolor = "Silver";
       $bgcount="0";
       for ($i=0; $i < 10; $i++ ) { 
        if ($bgcount == 1) {
         $bgcolor = "White";
         $bgcount = $bgcount + 1;
        }
        else {
         $bgcount = "0";
         $bgcolor="EFEFEF";
        }
        $rows = mysql_fetch_array($result);
       ?>
        OUTPUT DATA HERE
        <?PHP
        }
        ?>
 
After this has run, when I try to run another for() loop on the same
$result using the $rows variable it doesn't work. Any ideas?
 
 
Matt Babineau
Freelance Internet Developer
-----------------------------------------
e:  <mailto:[EMAIL PROTECTED]>
[EMAIL PROTECTED]
p: 603.943.4237
w:  <http://www.illuminatistudios.com/> http://www.illuminatistudios.com
 
--- End Message ---
--- Begin Message ---
Hi Matt,

in your code unfortunately it's not clear how you are
outputting data from an array, so I'm not sure... but
try reset($rows) function - it will set internal
pointer of array to first element... Consult manual
for array functions, specially for reset().

HTH, let me know

Piotr

--- Matt Babineau <[EMAIL PROTECTED]>
wrote:
> After I output data from a query with a for() loop,
> It seems like I
> cannot reuse the array from the query any more. Do I
> have to requery the
> database for the same info so that I can add up the
> database columns?
>  
>        <?PHP 
>        
>        $bgcolor = "Silver";
>        $bgcount="0";
>        for ($i=0; $i < 10; $i++ ) { 
>         if ($bgcount == 1) {
>          $bgcolor = "White";
>          $bgcount = $bgcount + 1;
>         }
>         else {
>          $bgcount = "0";
>          $bgcolor="EFEFEF";
>         }
>         $rows = mysql_fetch_array($result);
>        ?>
>         OUTPUT DATA HERE
>         <?PHP
>         }
>         ?>
>  
> After this has run, when I try to run another for()
> loop on the same
> $result using the $rows variable it doesn't work.
> Any ideas?
>  
>  
> Matt Babineau
> Freelance Internet Developer
> -----------------------------------------
> e:  <mailto:[EMAIL PROTECTED]>
> [EMAIL PROTECTED]
> p: 603.943.4237
> w:  <http://www.illuminatistudios.com/>
> http://www.illuminatistudios.com
>  
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Shopping - Mother's Day is May 12th!
http://shopping.yahoo.com
--- End Message ---
--- Begin Message ---
I think this is normal PHP behavior. The $result variable is considered an 
"array" by the MySQL functions, so every time you call mysql_fetch_, you 
remove an element from the "array" (I don't think it's really an array but 
it's the best comparison I could find).

My solution would be to create an array of your own and store each row into 
the array, but Piotr's idea might just do the trick.

Hope this helps,

Olivier

At 17:05 2002-05-09 -0400, Matt Babineau wrote:
>After I output data from a query with a for() loop, It seems like I
>cannot reuse the array from the query any more. Do I have to requery the
>database for the same info so that I can add up the database columns?
>
>        <?PHP
>
>        $bgcolor = "Silver";
>        $bgcount="0";
>        for ($i=0; $i < 10; $i++ ) {
>         if ($bgcount == 1) {
>          $bgcolor = "White";
>          $bgcount = $bgcount + 1;
>         }
>         else {
>          $bgcount = "0";
>          $bgcolor="EFEFEF";
>         }
>         $rows = mysql_fetch_array($result);
>        ?>
>         OUTPUT DATA HERE
>         <?PHP
>         }
>         ?>
>
>After this has run, when I try to run another for() loop on the same
>$result using the $rows variable it doesn't work. Any ideas?
>
>
>Matt Babineau
>Freelance Internet Developer
>-----------------------------------------
>e:  <mailto:[EMAIL PROTECTED]>
>[EMAIL PROTECTED]
>p: 603.943.4237
>w:  <http://www.illuminatistudios.com/> http://www.illuminatistudios.com

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

I have a question regarding XML parsing. Ok, I have an XML file that I'm
using to contain the data for an article. Within it, I have an <html>
</html> tag, where everything within those tags are just going to be
html.

However!! If I don't close a tag within there, let's say <p> the parser
is going to give me an error. Is there anyway I can stop this? I just
want everything within the <html> </html> not to be mucked with... like
any text within a tag? Well... I want it to work... how do I do it?

Thanks,
-cARL

--- End Message ---

Reply via email to