php-general Digest 29 May 2008 07:05:37 -0000 Issue 5485

Topics (messages 274780 through 274798):

Re: Calendar Date Help
        274780 by: Robert Cummings
        274782 by: Mark Weaver

Re: looking a regular expresion
        274781 by: Boyd, Todd M.

Re: In case this helps... (Calendar Date Help)
        274783 by: Mark Weaver
        274784 by: Robert Cummings
        274785 by: Robert Cummings
        274786 by: Mark Weaver
        274787 by: Mark Weaver

Reloading changes JS files?
        274788 by: Skip Evans
        274790 by: Skip Evans
        274792 by: Wolf
        274795 by: Jim Lucas

Query refuses to recurse all rows
        274789 by: celtic.aolohr.com
        274791 by: Chris
        274793 by: Wolf
        274796 by: Jim Lucas
        274797 by: celtic.aolohr.com

Re: Query refuses to recurse all rows {RESOLVED]
        274794 by: celtic.aolohr.com

Help mms (Get audio Stream)
        274798 by: Shelley

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 ---
On Wed, 2008-05-28 at 14:27 -0400, Mark Weaver wrote:
> Hi all,
> 
> I've put this off as long as possible, however I think I've reached an 
> impasse.
> 
> I've got an application that I've been writing. One of the modules for 
> this app is an event calendar. I've got the calendar to the place where 
> it displays the current month as well as previous and future months. The 
>   place I'm stuck is it will only show months in the past or the future 
> that are months in the current year.
> 
> Basically the method I'm using to move backward and forward is with Unix 
> timestamps.
> 
> 1. When the calendar first loads the "what" is checked for;
>       // passed in via $_GET
>       $what == current, prev, or next
>    a. "current" is the default
>       $now = time()
>       $prev = date('n',$now)-1
>       $next = date('n',$now)+1
>    b. Timestamp values are then stored in an array and then
>       sent to client in session cookie which is then accessed
>       upon each subsequent request to display the event calendar.
> 
> My question/boggle is why, when the calendar advances to 
> December(current year) it will display January, but of the current year. 
> The same happens in reverse.
> 
> Once I reach the end of the year either in the past or future the month 
> increases or decreases accordingly, but the year doesn't change. Since 
> the year value isn't changing the month calendar days that are displayed 
> simply repeat themselves.
> 
> I know there's something I'm missing, but I am definitely not seeing 
> what it is...
> 
> /********************** code below ************************/
> 
> $cal = new Calendar;
> $calpos = array();
>                       
> // check incoming values
> if ($what === "current"){
>       $cal->setCal(0,0,0,date('n'),1);
>       $now = time();
>       $prev = $cal->getStamp(date('n',$now)-1,1);
>       $next = $cal->getStamp(date('n',$now)+1,1);
>       $calpos['curr'] = $now;
>       $calpos['prev'] = $prev;
>       $calpos['next'] = $next;
>       $_SESSION['calendar'] = $calpos;
> }     
> elseif($what === "prev"){
>       $peek = $_SESSION['calendar'];
>       $now = $peek['prev'];
>       $cal->setCal(0,0,0,date('n',$now),1);
>       $prev = $cal->getStamp(date('n',$now)-1,1);
>       $next = $cal->getStamp(date('n',$now)+1,1);
>       $calpos['curr'] = $now;
>       $calpos['prev'] = $prev;
>       $calpos['next'] = $next;
>       $_SESSION['calendar'] = $calpos;
> }
> elseif($what === "next"){
>       $peek = $_SESSION['calendar'];
>       $now = $peek['next'];
>       $cal->setCal(0,0,0,date('n',$now),1);
>       $prev = $cal->getStamp(date('n',$now)-1,1);
>       $next = $cal->getStamp(date('n',$now)+1,1);
>       $calpos['curr'] = $now;
>       $calpos['prev'] = $prev;
>       $calpos['next'] = $next;
>       $_SESSION['calendar'] = $calpos;
> }
> 
> <================================================================>
> function setCal($h=0,$m=0,$s=0,$offset,$dayVal=1){            
>    $stamp = date('U',mktime($h,$m,$s, $offset,$dayVal,date('Y')));
                                                        ^^^^^^^^^
                                                        ^^^^^^^^^
                                                        ^^^^^^^^^
You don't want the current year. Fix this to a request year.

>    // Using the stamp the various necessary properties are set for the
>    // object
> 
> function getStamp($dateStr,$dayVal=1){
>    return date('U',mktime(0,0,0, $dateStr,$dayVal,date('Y')));
> }
                                                    ^^^^^^^^^
                                                    ^^^^^^^^^
                                                    ^^^^^^^^^
Similarly.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---
Robert Cummings wrote:
function getStamp($dateStr,$dayVal=1){
   return date('U',mktime(0,0,0, $dateStr,$dayVal,date('Y')));
}
                                                    ^^^^^^^^^
                                                    ^^^^^^^^^
                                                    ^^^^^^^^^
Similarly.

Cheers,
Rob.

Hi Rob,

Changing:
function setCal($h=0,$m=0,$s=0,$offset,$dayVal=1){              
   $stamp = date('U',mktime($h,$m,$s, $offset,$dayVal,date('Y')));

To:
function setCal($h=0,$m=0,$s=0,$offset,$dayVal=1){
  if (date('Y') > date('Y',date('U',mktime($h,$m,$s,
     $offset,$dayVal,date('Y')))))
  {
     $stamp = date('U',mktime($h,$m,$s, $offset,$dayVal,date('Y')+1));
  }
  else
  {
     $stamp = date('U',mktime($h,$m,$s, $offset,$dayVal,date('Y')));
  }

Makes no change. Strange condition still exists. I was rather hoping
that if "date('U',mktime($h,$m,$s, $offset,$dayVal,date('Y')))"
is smart enough to know to increase or decrease the month value that it
would do the same to the year value accordingly.

$offset contain either date('n',$timestamp)-1  or  date('n',$timestamp)+1

The $timestamp value comes from the array being stored in the
$_SESSION['calendar'] as either 'current', 'prev', or 'next'.

--

Mark
-------------------------
the rule of law is good, however the rule of tyrants just plain sucks!
Real Tax Reform begins with getting rid of the IRS.
==============================================
Powered by CentOS5 (RHEL5)


--- End Message ---
--- Begin Message ---
>> -----Original Message-----

>> From: Manuel Pérez López [mailto:[EMAIL PROTECTED]

>> Sent: Tuesday, May 27, 2008 2:06 PM

>> To: [EMAIL PROTECTED]

>> Subject: [PHP] looking a regular expresion

>> 

>> Hello:

>> 

>> I need to include a pair of negations with two complete word into a 

>> regular expresion for preg_replace. How to do this?

>> I want to replace "I want to be a SUN and a SIR" with "FRIKI FRIKI 

>> FRIKI FRIKI FRIKI SUN FRIKI FRIKI SIR"

>> 

>> ie. the words are: SUN and SIR. And the replacement word is: FRIKI

>> 

>> $st = preg_replace ("\b([^S][^U][^N])|([^S][^I][^R]\b)", "FRIKI",$st);

>> 

>> This does not  match

>> 

>> Anyone hep me?

>> 

>> Thanks

> 

>Man... this is really irritating the heck out of me. I have recently been 
>learning regular expressions, and >thought I was "fresh" enough to fix this 
>with new eyes. However, I've been running into all kinds of trouble, >and I 
>now impatiently anticipate an expert's answer, much the same as you. :)

> 

>It's interesting to me that ``$st = preg_replace("(SUN)", "FRIKI", $st);`` 
>replaces the word "SUN" with the >word "FRIKI", but ``$st = 
>preg_replace("(^SUN)", "FRIKI", $st);`` does the same thing (when it should be 
>>replacing everything BUT the word "SUN").

> 

>Annoying behavior. Is this particular to PHP's regular expression engine? I 
>should try this in VB.NET and see >what the results are, as that's what I'm 
>used to playing with (for the time being).

 

Okay, I think I figured it out!

 

$st = "SUN ASDF SIR BLAH SIR SIR SUN";

$st = preg_replace ("/(?!\b(SUN|SIR)\b)\b\w+\b/", "FRIKI", $st);

echo $st;

 

It involves a "lookaround," so I'm not sure how efficient it is-but it works! 
Man, that's a load off my mind. It's not as simple as it would have seemed at 
first... but now that I have a look at the finished regex string, it makes 
sense.

 

"If there's not a word boundary followed by either SIR or SUN followed by 
another word boundary, start over. Now, if there's a word boundary followed by 
1 or more word characters followed by another word boundary, replace that with 
FRIKI."

 

Hope this helps!!

 

 

Todd Boyd

Web Programmer


--- End Message ---
--- Begin Message ---
Mark Weaver wrote:
Hi all,

I've put this off as long as possible, however I think I've reached an impasse.

I've got an application that I've been writing. One of the modules for this app is an event calendar. I've got the calendar to the place where it displays the current month as well as previous and future months. The place I'm stuck is it will only show months in the past or the future that are months in the current year.

Basically the method I'm using to move backward and forward is with Unix timestamps.

1. When the calendar first loads the "what" is checked for;
    // passed in via $_GET
    $what == current, prev, or next
  a. "current" is the default
    $now = time()
    $prev = date('n',$now)-1
    $next = date('n',$now)+1
  b. Timestamp values are then stored in an array and then
    sent to client in session cookie which is then accessed
    upon each subsequent request to display the event calendar.

My question/boggle is why, when the calendar advances to December(current year) it will display January, but of the current year. The same happens in reverse.

Once I reach the end of the year either in the past or future the month increases or decreases accordingly, but the year doesn't change. Since the year value isn't changing the month calendar days that are displayed simply repeat themselves.

I know there's something I'm missing, but I am definitely not seeing what it is...

/********************** code below ************************/

$cal = new Calendar;
$calpos = array();
// check incoming values
if ($what === "current"){
    $cal->setCal(0,0,0,date('n'),1);
    $now = time();
    $prev = $cal->getStamp(date('n',$now)-1,1);
    $next = $cal->getStamp(date('n',$now)+1,1);
    $calpos['curr'] = $now;
    $calpos['prev'] = $prev;
    $calpos['next'] = $next;
    $_SESSION['calendar'] = $calpos;
} elseif($what === "prev"){
    $peek = $_SESSION['calendar'];
    $now = $peek['prev'];
    $cal->setCal(0,0,0,date('n',$now),1);
    $prev = $cal->getStamp(date('n',$now)-1,1);
    $next = $cal->getStamp(date('n',$now)+1,1);
    $calpos['curr'] = $now;
    $calpos['prev'] = $prev;
    $calpos['next'] = $next;
    $_SESSION['calendar'] = $calpos;
}
elseif($what === "next"){
    $peek = $_SESSION['calendar'];
    $now = $peek['next'];
    $cal->setCal(0,0,0,date('n',$now),1);
    $prev = $cal->getStamp(date('n',$now)-1,1);
    $next = $cal->getStamp(date('n',$now)+1,1);
    $calpos['curr'] = $now;
    $calpos['prev'] = $prev;
    $calpos['next'] = $next;
    $_SESSION['calendar'] = $calpos;
}

<================================================================>
function setCal($h=0,$m=0,$s=0,$offset,$dayVal=1){ $stamp = date('U',mktime($h,$m,$s, $offset,$dayVal,date('Y')));
  // Using the stamp the various necessary properties are set for the
  // object

function getStamp($dateStr,$dayVal=1){
  return date('U',mktime(0,0,0, $dateStr,$dayVal,date('Y')));
}


After scratching my head on this for a few hours I'm still no closer to the solution, but essentially what I need to do in the getStamp function is test the {year} of the stamp that results from the incoming $dateStr against the actual {year} value of the current year's timestamp time().

In case it helps below is the code being used in it's entirety.
The first block of code is the Calendar class and the second is the code for the page which displays the event calendar.

my appologies if it's all jumbled up.

/********************* Calendar Class ***********************/
class Calendar{
        
public $month,$weekday,$dayname,$monthname,$numdays,$year,$mday,$dbdate,$today,$fday;
        
        public function Calendar(){
                @$this->month = $month;
                @$this->weekday = $weekday;
                @$this->dayname = $dayname;
                @$this->monthname = $monthname;
                @$this->numdays = $numdays;
                @$this->year = $year;
                @$this->mday = $mday;
                @$this->dbdate = $dbdate;
                @$this->fday = $fday;
        }
        
        public function setCal($h=0,$m=0,$s=0,$offset,$dayVal=1){
                $stamp = date('U',mktime($h,$m,$s, $offset,$dayVal,date('Y')));
                
                $month = date('m',$stamp);              // month value with 
leading zero
                $mday = date('d',$stamp);               // day value with 
leading zero
                $dbdate = date('Y-m-d',$stamp); 
                $dayname = date('l',$stamp);
                $monthname = date('F',$stamp);
                $numdays = date('t',$stamp);
                $year = date('Y',$stamp);
                $weekday = date('w',$stamp);
                $fday = date('w', mktime(0, 0, 0, date('n',$stamp), 1, 
date('Y',$stamp)));
                
                $this->month = $month;
                $this->weekday = $weekday;
                $this->dayname = $dayname;
                $this->monthname = $monthname;
                $this->numdays = $numdays;
                $this->year = $year;
                $this->mday = $mday;
                $this->dbdate = $dbdate;
                $this->fday = $fday;
        }
        
        public function getTodayNum(){
                return date('j',time());
        }
        
        public function getStamp($dateStr,$dayVal=1){
                return date('U',mktime(0,0,0, $dateStr,$dayVal,date('Y')));
        }
                
        public function getMonthName(){
                return $this->monthname;
        }
        
        public function getTodayName(){
                return $this->dayname;
        }
        
        public function getDay(){
                return $this->weekday;
        }
        
        public function getMday($stamp){
                return date('j',$stamp);
        }

}
/**********************************************************/

/********************* Event Calendar Page ****************/
function display_calendar($what){
        include 'config.php';
        require_once 'inc/MyDB.inc';
        require_once 'inc/forms.inc';
        require_once 'inc/Calendar.inc';
        @session_start();
        
        if ( isset($_SESSION['TSUser']) ){
                // set userObj from Session
                $userObj = $_SESSION['TSUser'];
                $cal = new Calendar;
                $calpos = array();
                
                // check incoming values
                if ($what === "current"){
                        $cal->setCal(0,0,0,date('n'),1);
                        $now = time();
                        $prev = $cal->getStamp(date('n',$now)-1,1);
                        $next = $cal->getStamp(date('n',$now)+1,1);
                        $calpos['curr'] = $now;
                        $calpos['prev'] = $prev;
                        $calpos['next'] = $next;
                        $_SESSION['calendar'] = $calpos;
                }       
                elseif($what === "prev"){
                        $peek = $_SESSION['calendar'];
                        $now = $peek['prev'];
                        $cal->setCal(0,0,0,date('n',$now),1);
                        $prev = $cal->getStamp(date('n',$now)-1,1);
                        $next = $cal->getStamp(date('n',$now)+1,1);
                        $calpos['curr'] = $now;
                        $calpos['prev'] = $prev;
                        $calpos['next'] = $next;
                        $_SESSION['calendar'] = $calpos;
                }
                elseif($what === "next"){
                        $peek = $_SESSION['calendar'];
                        $now = $peek['next'];
                        $cal->setCal(0,0,0,date('n',$now),1);
                        $prev = $cal->getStamp(date('n',$now)-1,1);
                        $next = $cal->getStamp(date('n',$now)+1,1);
                        $calpos['curr'] = $now;
                        $calpos['prev'] = $prev;
                        $calpos['next'] = $next;
                        $_SESSION['calendar'] = $calpos;
                }               
                                        
                $totalweeks = ($cal->numdays/7);
                pageHeader("Calendar: {$userObj['user']}","","");
                pageContainers();
                echo "<BR>\n";
                        
echo "<table style=\"border-left: 1px solid #000000; border-top: 1px solid #000000;\" border=0 cellpadding=0 cellspacing=0>\n";
                echo "<tr><td colspan=7 height=30 align=center><h1>";
                echo $cal->monthname . "&nbsp;&nbsp;&nbsp;&nbsp;" . $cal->year;
                echo "</h1></td></tr>\n";
                $todaysMonthNum = $cal->getTodayNum();
                        
                $back = "<a href=\"index.php?page=show_calendar&cal=prev\">< < 
Back</a>";
$forward = "<a href=\"index.php?page=show_calendar&cal=next\">Forward > ></a>";
                        
echo "<tr align=center><td colspan=2>{$back}</td><td colspan=3><a href=\"index.php?page=show_calendar&cal=current\">Current Month</a></td><td colspan=2>{$forward}</td></tr>\n"; echo "<tr align=center><td>Sunday</td><td>Monday</td><td>Tuesday</td><td>Wednesday</td><td>Thursday</td><td>Friday</td><td>Saturday</td>\n";
                $totalweeks = ($cal->numdays/7);
                $cday = 1;
                $carr = array(array());
                $bkgrnd = '';
                
                for($i=0;$i<$totalweeks;$i++){
                        echo "<tr>\n";
                        for ($d=0;$d<7;$d++){
                                if ( $d<$cal->fday && $i==0){
echo "<td valign=top width=145 height=110 style=\"border-right: 1px solid #000000; border-bottom: 1px solid #000000;\">";
                                        $carr[$i][$d] = "&nbsp;";
                                        echo $carr[$i][$d];
                                        echo "</td>";
                                }
                                else{
                                        if ( $cday == $cal->getTodayNum() ){
                                        $bkgrnd = "#cccccc";
                                        }
                                        else{
                                                $bkgrnd = '';
                                        }
echo "<td bgcolor=\"{$bkgrnd}\" valign=top width=145 height=110 style=\"border-right: 1px solid #000000; border-bottom: 1px solid #000000;\">";
                                $carr[$i][$d] = $cday;
                                $cday++;
                                echo $carr[$i][$d];
                                echo "</td>";
                                }
                                if($cday > $cal->numdays){
                                        break;
                                }
                        }
                        echo "</tr>\n";
                        $d = 0;
                }
                
                echo "</table>\n";
                pageFooter();
        }
        else{
                noValidSession();
        }
}

--

Mark
-------------------------
the rule of law is good, however the rule of tyrants just plain sucks!
Real Tax Reform begins with getting rid of the IRS.
==============================================
Powered by CentOS5 (RHEL5)

--- End Message ---
--- Begin Message ---
Out of curiosity.. have you thought about reworking your premise? Using
prev, current, and next is extremely sloppy IMHO. Additionally, it
prevents bookmarking a specific calendar date. Why don't you have a date
parameter that indicates the year and month? If no such field exists
then you fallback to current date. Then the situation becomes trivial
and doesn't require dependence on the session. Having looked at your
code it strikes me as very poorly thought out which makes it difficult
to ascertain your current problem. At any rate, it's obviously more
complex than is necessary.

<?php

$date = isset( $_GET['date'] ) ? $_GET['date'] : date( 'Y-m' );
list( $year, $month ) = explode( '-', $date );
$timestampCurr = mktime( 0, 0, 0, $month, 1, $year );

$timestampPrev = strtotime( '-1 month', date( 'Y-m-d', $timestamp ) );
$timestampNext = strtotime( '+1 month', date( 'Y-m-d', $timestamp ) );

echo '<a href="?date='.date( 'Y-m', $timestampPrev ).'">Prev</a><br />';
echo '<a href="?date='.date( 'Y-m', $timestampCurr ).'">Curr</a><br />';
echo '<a href="?date='.date( 'Y-m', $timestampNext ).'">Next</a><br />';

?>

I'm sure you could wire the above into your Calendar class easy enough.
FYI it's untested :)

Cheers,
Rob.



On Wed, 2008-05-28 at 16:18 -0400, Mark Weaver wrote:
> Mark Weaver wrote:
> > Hi all,
> > 
> > I've put this off as long as possible, however I think I've reached an 
> > impasse.
> > 
> > I've got an application that I've been writing. One of the modules for 
> > this app is an event calendar. I've got the calendar to the place where 
> > it displays the current month as well as previous and future months. The 
> >  place I'm stuck is it will only show months in the past or the future 
> > that are months in the current year.
> > 
> > Basically the method I'm using to move backward and forward is with Unix 
> > timestamps.
> > 
> > 1. When the calendar first loads the "what" is checked for;
> >     // passed in via $_GET
> >     $what == current, prev, or next
> >   a. "current" is the default
> >     $now = time()
> >     $prev = date('n',$now)-1
> >     $next = date('n',$now)+1
> >   b. Timestamp values are then stored in an array and then
> >     sent to client in session cookie which is then accessed
> >     upon each subsequent request to display the event calendar.
> > 
> > My question/boggle is why, when the calendar advances to 
> > December(current year) it will display January, but of the current year. 
> > The same happens in reverse.
> > 
> > Once I reach the end of the year either in the past or future the month 
> > increases or decreases accordingly, but the year doesn't change. Since 
> > the year value isn't changing the month calendar days that are displayed 
> > simply repeat themselves.
> > 
> > I know there's something I'm missing, but I am definitely not seeing 
> > what it is...
> > 
> > /********************** code below ************************/
> > 
> > $cal = new Calendar;
> > $calpos = array();
> >            
> > // check incoming values
> > if ($what === "current"){
> >     $cal->setCal(0,0,0,date('n'),1);
> >     $now = time();
> >     $prev = $cal->getStamp(date('n',$now)-1,1);
> >     $next = $cal->getStamp(date('n',$now)+1,1);
> >     $calpos['curr'] = $now;
> >     $calpos['prev'] = $prev;
> >     $calpos['next'] = $next;
> >     $_SESSION['calendar'] = $calpos;
> > }   
> > elseif($what === "prev"){
> >     $peek = $_SESSION['calendar'];
> >     $now = $peek['prev'];
> >     $cal->setCal(0,0,0,date('n',$now),1);
> >     $prev = $cal->getStamp(date('n',$now)-1,1);
> >     $next = $cal->getStamp(date('n',$now)+1,1);
> >     $calpos['curr'] = $now;
> >     $calpos['prev'] = $prev;
> >     $calpos['next'] = $next;
> >     $_SESSION['calendar'] = $calpos;
> > }
> > elseif($what === "next"){
> >     $peek = $_SESSION['calendar'];
> >     $now = $peek['next'];
> >     $cal->setCal(0,0,0,date('n',$now),1);
> >     $prev = $cal->getStamp(date('n',$now)-1,1);
> >     $next = $cal->getStamp(date('n',$now)+1,1);
> >     $calpos['curr'] = $now;
> >     $calpos['prev'] = $prev;
> >     $calpos['next'] = $next;
> >     $_SESSION['calendar'] = $calpos;
> > }
> > 
> > <================================================================>
> > function setCal($h=0,$m=0,$s=0,$offset,$dayVal=1){       
> >   $stamp = date('U',mktime($h,$m,$s, $offset,$dayVal,date('Y')));
> >   // Using the stamp the various necessary properties are set for the
> >   // object
> > 
> > function getStamp($dateStr,$dayVal=1){
> >   return date('U',mktime(0,0,0, $dateStr,$dayVal,date('Y')));
> > }
> > 
> 
> After scratching my head on this for a few hours I'm still no closer to 
> the solution, but essentially what I need to do in the getStamp function 
> is test the {year} of the stamp that results from the incoming $dateStr 
> against the actual {year} value of the current year's timestamp time().
> 
> In case it helps below is the code being used in it's entirety.
> The first block of code is the Calendar class and the second is the code 
>   for the page which displays the event calendar.
> 
> my appologies if it's all jumbled up.
> 
> /********************* Calendar Class ***********************/
> class Calendar{
>       
>       public 
> $month,$weekday,$dayname,$monthname,$numdays,$year,$mday,$dbdate,$today,$fday;
>       
>       public function Calendar(){
>               @$this->month = $month;
>               @$this->weekday = $weekday;
>               @$this->dayname = $dayname;
>               @$this->monthname = $monthname;
>               @$this->numdays = $numdays;
>               @$this->year = $year;
>               @$this->mday = $mday;
>               @$this->dbdate = $dbdate;
>               @$this->fday = $fday;
>       }
>       
>       public function setCal($h=0,$m=0,$s=0,$offset,$dayVal=1){
>               $stamp = date('U',mktime($h,$m,$s, $offset,$dayVal,date('Y')));
>               
>               $month = date('m',$stamp);              // month value with 
> leading zero
>               $mday = date('d',$stamp);               // day value with 
> leading zero
>               $dbdate = date('Y-m-d',$stamp); 
>               $dayname = date('l',$stamp);
>               $monthname = date('F',$stamp);
>               $numdays = date('t',$stamp);
>               $year = date('Y',$stamp);
>               $weekday = date('w',$stamp);
>               $fday = date('w', mktime(0, 0, 0, date('n',$stamp), 1, 
> date('Y',$stamp)));
>               
>               $this->month = $month;
>               $this->weekday = $weekday;
>               $this->dayname = $dayname;
>               $this->monthname = $monthname;
>               $this->numdays = $numdays;
>               $this->year = $year;
>               $this->mday = $mday;
>               $this->dbdate = $dbdate;
>               $this->fday = $fday;
>       }
>       
>       public function getTodayNum(){
>               return date('j',time());
>       }
>       
>       public function getStamp($dateStr,$dayVal=1){
>               return date('U',mktime(0,0,0, $dateStr,$dayVal,date('Y')));
>       }
>               
>       public function getMonthName(){
>               return $this->monthname;
>       }
>       
>       public function getTodayName(){
>               return $this->dayname;
>       }
>       
>       public function getDay(){
>               return $this->weekday;
>       }
>       
>       public function getMday($stamp){
>               return date('j',$stamp);
>       }
> 
> }
> /**********************************************************/
> 
> /********************* Event Calendar Page ****************/
> function display_calendar($what){
>       include 'config.php';
>       require_once 'inc/MyDB.inc';
>       require_once 'inc/forms.inc';
>       require_once 'inc/Calendar.inc';
>       @session_start();
>       
>       if ( isset($_SESSION['TSUser']) ){
>               // set userObj from Session
>               $userObj = $_SESSION['TSUser'];
>               $cal = new Calendar;
>               $calpos = array();
>               
>               // check incoming values
>               if ($what === "current"){
>                       $cal->setCal(0,0,0,date('n'),1);
>                       $now = time();
>                       $prev = $cal->getStamp(date('n',$now)-1,1);
>                       $next = $cal->getStamp(date('n',$now)+1,1);
>                       $calpos['curr'] = $now;
>                       $calpos['prev'] = $prev;
>                       $calpos['next'] = $next;
>                       $_SESSION['calendar'] = $calpos;
>               }       
>               elseif($what === "prev"){
>                       $peek = $_SESSION['calendar'];
>                       $now = $peek['prev'];
>                       $cal->setCal(0,0,0,date('n',$now),1);
>                       $prev = $cal->getStamp(date('n',$now)-1,1);
>                       $next = $cal->getStamp(date('n',$now)+1,1);
>                       $calpos['curr'] = $now;
>                       $calpos['prev'] = $prev;
>                       $calpos['next'] = $next;
>                       $_SESSION['calendar'] = $calpos;
>               }
>               elseif($what === "next"){
>                       $peek = $_SESSION['calendar'];
>                       $now = $peek['next'];
>                       $cal->setCal(0,0,0,date('n',$now),1);
>                       $prev = $cal->getStamp(date('n',$now)-1,1);
>                       $next = $cal->getStamp(date('n',$now)+1,1);
>                       $calpos['curr'] = $now;
>                       $calpos['prev'] = $prev;
>                       $calpos['next'] = $next;
>                       $_SESSION['calendar'] = $calpos;
>               }               
>                                       
>               $totalweeks = ($cal->numdays/7);
>               pageHeader("Calendar: {$userObj['user']}","","");
>               pageContainers();
>               echo "<BR>\n";
>                       
>               echo "<table style=\"border-left: 1px solid #000000; 
> border-top: 1px 
> solid #000000;\" border=0 cellpadding=0 cellspacing=0>\n";
>               echo "<tr><td colspan=7 height=30 align=center><h1>";
>               echo $cal->monthname . "&nbsp;&nbsp;&nbsp;&nbsp;" . $cal->year;
>               echo "</h1></td></tr>\n";
>               $todaysMonthNum = $cal->getTodayNum();
>                       
>               $back = "<a href=\"index.php?page=show_calendar&cal=prev\">< < 
> Back</a>";
>               $forward = "<a 
> href=\"index.php?page=show_calendar&cal=next\">Forward 
>  > ></a>";
>                       
>               echo "<tr align=center><td colspan=2>{$back}</td><td 
> colspan=3><a 
> href=\"index.php?page=show_calendar&cal=current\">Current 
> Month</a></td><td colspan=2>{$forward}</td></tr>\n";
>               echo "<tr 
> align=center><td>Sunday</td><td>Monday</td><td>Tuesday</td><td>Wednesday</td><td>Thursday</td><td>Friday</td><td>Saturday</td>\n";
>               $totalweeks = ($cal->numdays/7);
>               $cday = 1;
>               $carr = array(array());
>               $bkgrnd = '';
>               
>               for($i=0;$i<$totalweeks;$i++){
>                       echo "<tr>\n";
>                       for ($d=0;$d<7;$d++){
>                               if ( $d<$cal->fday && $i==0){
>                                       echo "<td valign=top width=145 
> height=110 style=\"border-right: 1px 
> solid #000000; border-bottom: 1px solid #000000;\">";
>                                       $carr[$i][$d] = "&nbsp;";
>                                       echo $carr[$i][$d];
>                                       echo "</td>";
>                               }
>                               else{
>                                       if ( $cday == $cal->getTodayNum() ){
>                                       $bkgrnd = "#cccccc";
>                                       }
>                                       else{
>                                               $bkgrnd = '';
>                                       }
>                                               echo "<td bgcolor=\"{$bkgrnd}\" 
> valign=top width=145 height=110 
> style=\"border-right: 1px solid #000000; border-bottom: 1px solid 
> #000000;\">";
>                               $carr[$i][$d] = $cday;
>                               $cday++;
>                               echo $carr[$i][$d];
>                               echo "</td>";
>                               }
>                               if($cday > $cal->numdays){
>                                       break;
>                               }
>                       }
>                       echo "</tr>\n";
>                       $d = 0;
>               }
>               
>               echo "</table>\n";
>               pageFooter();
>       }
>       else{
>               noValidSession();
>       }
> }
> 
> -- 
> 
> Mark
> -------------------------
> the rule of law is good, however the rule of tyrants just plain sucks!
> Real Tax Reform begins with getting rid of the IRS.
> ==============================================
> Powered by CentOS5 (RHEL5)
> 
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---
On Wed, 2008-05-28 at 16:47 -0400, Robert Cummings wrote:
> Out of curiosity.. have you thought about reworking your premise? Using
> prev, current, and next is extremely sloppy IMHO. Additionally, it
> prevents bookmarking a specific calendar date. Why don't you have a date
> parameter that indicates the year and month? If no such field exists
> then you fallback to current date. Then the situation becomes trivial
> and doesn't require dependence on the session. Having looked at your
> code it strikes me as very poorly thought out which makes it difficult
> to ascertain your current problem. At any rate, it's obviously more
> complex than is necessary.
> 
> <?php
> 
> $date = isset( $_GET['date'] ) ? $_GET['date'] : date( 'Y-m' );
> list( $year, $month ) = explode( '-', $date );
> $timestampCurr = mktime( 0, 0, 0, $month, 1, $year );
> 
> $timestampPrev = strtotime( '-1 month', date( 'Y-m-d', $timestamp ) );
> $timestampNext = strtotime( '+1 month', date( 'Y-m-d', $timestamp ) );

Those two lines above should be:

$timestampPrev = strtotime( '-1 month', $timestampCurr );
$timestampNext = strtotime( '+1 month', $timestampCurr );

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---
Robert Cummings wrote:
Out of curiosity.. have you thought about reworking your premise? Using
prev, current, and next is extremely sloppy IMHO. Additionally, it
prevents bookmarking a specific calendar date. Why don't you have a date
parameter that indicates the year and month? If no such field exists
then you fallback to current date. Then the situation becomes trivial
and doesn't require dependence on the session. Having looked at your
code it strikes me as very poorly thought out which makes it difficult
to ascertain your current problem. At any rate, it's obviously more
complex than is necessary.

<?php

$date = isset( $_GET['date'] ) ? $_GET['date'] : date( 'Y-m' );
list( $year, $month ) = explode( '-', $date );
$timestampCurr = mktime( 0, 0, 0, $month, 1, $year );

$timestampPrev = strtotime( '-1 month', date( 'Y-m-d', $timestamp ) );
$timestampNext = strtotime( '+1 month', date( 'Y-m-d', $timestamp ) );

echo '<a href="?date='.date( 'Y-m', $timestampPrev ).'">Prev</a><br />';
echo '<a href="?date='.date( 'Y-m', $timestampCurr ).'">Curr</a><br />';
echo '<a href="?date='.date( 'Y-m', $timestampNext ).'">Next</a><br />';

?>

Well, of course it's sloppy. I've only been coding PHP OOP since January. :) Given the app is barely in the alpha stage I wanted to start with a simple premise and wait till development is further along to make the ugly bits more elegant.

At the moment I don't understand why getStamp() isn't taking $dateStr and returning the the {year} for date stamps in past or future outside the current year.

(value being passed to getStamp() inside $dateStr is 'date('Y')-1')

When I can understand what I'm currently doing wrong premise changing will likely make a lot more sense.

--

Mark
-------------------------
the rule of law is good, however the rule of tyrants just plain sucks!
Real Tax Reform begins with getting rid of the IRS.
==============================================
Powered by CentOS5 (RHEL5)

--- End Message ---
--- Begin Message ---
Robert Cummings wrote:
On Wed, 2008-05-28 at 16:47 -0400, Robert Cummings wrote:
Out of curiosity.. have you thought about reworking your premise? Using
prev, current, and next is extremely sloppy IMHO. Additionally, it
prevents bookmarking a specific calendar date. Why don't you have a date
parameter that indicates the year and month? If no such field exists
then you fallback to current date. Then the situation becomes trivial
and doesn't require dependence on the session. Having looked at your
code it strikes me as very poorly thought out which makes it difficult
to ascertain your current problem. At any rate, it's obviously more
complex than is necessary.

<?php

$date = isset( $_GET['date'] ) ? $_GET['date'] : date( 'Y-m' );
list( $year, $month ) = explode( '-', $date );
$timestampCurr = mktime( 0, 0, 0, $month, 1, $year );

$timestampPrev = strtotime( '-1 month', date( 'Y-m-d', $timestamp ) );
$timestampNext = strtotime( '+1 month', date( 'Y-m-d', $timestamp ) );

Those two lines above should be:

$timestampPrev = strtotime( '-1 month', $timestampCurr );
$timestampNext = strtotime( '+1 month', $timestampCurr );

Cheers,
Rob.

Ok... I've made a change to getStamp() using the two lines above to see what would happen, however the results are the same. If I move through the months up to December the calendar moves normally and correctly. But, once I get to January it displays January for 2008 and never increments the year.

getStamp() now looks like this:
public function getStamp($stamp,$d){
        if ($d === 1){
                return strtotime( '+1 month', $stamp );
        }
        elseif($d === 0){
                return strtotime( '-1 month', $stamp );
        }
}

I know it's a matter of me not understanding fully what I'm doing; I'm just not sure where to go from here.

--

Mark
-------------------------
the rule of law is good, however the rule of tyrants just plain sucks!
Real Tax Reform begins with getting rid of the IRS.
==============================================
Powered by CentOS5 (RHEL5)

--- End Message ---
--- Begin Message ---
Hey all,

I have an HTML template file I read into a PHP script and then after supplying dynamic data I send the template to the browser with

echo $html;

The HTML template contains many JS files in the <head>...</head> section referenced like this:

<script src="ajax/players.js" type="text/javascript"></script>

My question is this: how can I cause the JS files on the header.html file to be reloaded to the browser when ever they have been modified?

I'm looking now at the last-modified header stuff, but not sure this will do what I want. I'll keep reading up on this, but if someone can point me in the right direction that would be great.
--
Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison, WI 53703
608-250-2720
http://bigskypenguin.com
=-=-=-=-=-=-=-=-=-=
Check out PHPenguin, a lightweight and versatile
PHP/MySQL, AJAX & DHTML development framework.
http://phpenguin.bigskypenguin.com/

--- End Message ---
--- Begin Message ---
Hey all,

I don't know if it's practical to change the name of the file when they are updated, but another thing I found along similar lines reading up on this was something like this was:

ajax/players.js?version=21

Would that also do it?

Not sure what the server is sending for EXPIRES, looking up how to determine that now.

Skip

[EMAIL PROTECTED] wrote:
Use a version numbered name for the js? e.g. ajax/players21.js

What does your server send for the EXPIRES for js files? i.e. what have you
told the browser to cache. What is the browser cache policy?

David


--
Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison, WI 53703
608-250-2720
http://bigskypenguin.com
=-=-=-=-=-=-=-=-=-=
Check out PHPenguin, a lightweight and versatile
PHP/MySQL, AJAX & DHTML development framework.
http://phpenguin.bigskypenguin.com/

--- End Message ---
--- Begin Message ---
Skip Evans wrote:
Hey all,

I don't know if it's practical to change the name of the file when they are updated, but another thing I found along similar lines reading up on this was something like this was:

ajax/players.js?version=21

Would that also do it?

Not sure what the server is sending for EXPIRES, looking up how to determine that now.

Skip

[EMAIL PROTECTED] wrote:
Use a version numbered name for the js? e.g. ajax/players21.js

What does your server send for the EXPIRES for js files? i.e. what have you
told the browser to cache. What is the browser cache policy?

David



I've never seen the version number actually used except when you take into account that the number MIGHT change which means that they should get a new file when the server loads the page.

Other then that you either have to rely on the client's browser to listen to your "expires" setting, or hope they don't have their browser over-ride yours.

The best thing I can recommend is having the .js code directly coded into the page as you server it instead of linking in the files.

Or write code that is compatible no matter which version of your JS they have.

IE: if you have all of your menus and such in JS code, rethink how you coded. Also remember, not everyone runs JS or JAVA, some of us actually disable it as a matter of course.

Which means your site breaks US federal guidelines when it becomes unusable to those who don't have flash/js/java/shockwave.

Wolf


--- End Message ---
--- Begin Message ---
Skip Evans wrote:
Hey all,

I have an HTML template file I read into a PHP script and then after supplying dynamic data I send the template to the browser with

echo $html;

The HTML template contains many JS files in the <head>...</head> section referenced like this:

<script src="ajax/players.js" type="text/javascript"></script>

My question is this: how can I cause the JS files on the header.html file to be reloaded to the browser when ever they have been modified?

I'm looking now at the last-modified header stuff, but not sure this will do what I want. I'll keep reading up on this, but if someone can point me in the right direction that would be great.

In a past project we had the same type of problem, but with jpegs.

The solution was to add the unix modification time to the src path

<img src='/image/bulk.jpg?112344324' />

anything after the question mark will get ignored by the browser. Except that the browser will think that it is a new URL that it has never seen before and it will call to the server for a fresh copy of the file.

Jim Lucas

--- End Message ---
--- Begin Message ---
Hi,
 
In the following code, only the first row from query1 displays along with the 
display stuff from query3. The problem: query1 refuses to recurse to the next 
and following rows. 

It appears that the sub-queries in the main query cause the $row++; not to 
work.

Is there some conditional that might it prompt it to do so? 

I'm stumped - worked at variations for a few days. Any help, pointers, 
suggestions most gratefully welcome!



<?php

include("dbc.php");
if (!$db){ $_SESSION['db'] = "select-thread"; session_write_close(); 
header("location: db.php");}

        $query1 = "SELECT * FROM replies WHERE mid = '{$_SESSION['mid']}'";
                                                        
                $result1 = pg_exec($db, $query1);
                if (!$result1) { exit;}
        
                $numrows1 = pg_numrows($result1);
                $row = 0;
                do
                {
                        $myrow = pg_fetch_array($result1, $row);        
        
                                /* display stuff */



                                $query2 = "SELECT * FROM subs WHERE mid = 
'{$_SESSION['mid']}' AND 
                                                rid = '{$myrow['rid']}'";

                                        $result2 = pg_exec($db, $query2);
                                        if (!$result2) { exit;}
                                
                                        $numrows2 = pg_numrows($result2);
                                        $row = 0;
                                        do
                                        {
                                                $myrow = 
pg_fetch_array($result2, $row);        
                
                                                        /* display stuff */
        
                                        $row++;
                                        }
                                        while ($row < $numrows2);
        
        
        
        
                                $query3 = "SELECT * FROM subs where subsid = 
'{$_SESSION['subsid']}' 
                                                AND rid = '{$myrow['rid']}' AND 
responded = '1'";
        
                                        $result3 = pg_exec($db, $query3);
                                        if (!$result3) { exit;}
                                
                                        $numrows3 = pg_numrows($result3);
                                        $row = 0;
                                        do
                                        {
                                        $myrow = pg_fetch_array($result3, 
$row);        
        
                                                /* display stuff */
        
                                        $row++;
                                        }
                                        while ($row < $numrows3);....

                
                $row++;         
                }
                while ($row < $numrows1);

?>

--- End Message ---
--- Begin Message ---
>               $numrows1 = pg_numrows($result1);
>               $row = 0;
>               do
>               {
>                       $myrow = pg_fetch_array($result1, $row);        

<snip>

>                                       $numrows2 = pg_numrows($result2);
>                                       $row = 0;
>                                       do
>                                       {
>                                               $myrow = 
> pg_fetch_array($result2, $row);        

You're overwriting your variables.

$myrow from result 1 is being killed off when it gets into the $myrow
loop from result 2.

-- 
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
Chris wrote:
                $numrows1 = pg_numrows($result1);
                $row = 0;
                do
                {
                        $myrow = pg_fetch_array($result1, $row);        

<snip>

                                        $numrows2 = pg_numrows($result2);
                                        $row = 0;
                                        do
                                        {
                                                $myrow = 
pg_fetch_array($result2, $row);        

You're overwriting your variables.

$myrow from result 1 is being killed off when it gets into the $myrow
loop from result 2.


Yeah, what Chris said!

When you are looping inside another piece, make sure to change up all your variables.
use a $j inside an $i, a $l inside a $k, $rowa inside a $row

Woulda saved yourself a day of playing...

Remember, the variable scope changes inside a function or class, but outside of that they pretty much run the whole length of the script.

HTH,
Wolf



--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED] wrote:
Hi,
In the following code, only the first row from query1 displays along with the display stuff from query3. The problem: query1 refuses to recurse to the next and following rows. It appears that the sub-queries in the main query cause the $row++; not to work.

Is there some conditional that might it prompt it to do so? I'm stumped - worked at variations for a few days. Any help, pointers, suggestions most gratefully welcome!



<?php

include("dbc.php");
if (!$db){ $_SESSION['db'] = "select-thread"; session_write_close(); header("location: db.php");}

        $query1 = "SELECT * FROM replies WHERE mid = '{$_SESSION['mid']}'";
                                                        
                $result1 = pg_exec($db, $query1);
                if (!$result1) { exit;}
        
                $numrows1 = pg_numrows($result1);
                $row = 0;
                do
                {
                        $myrow = pg_fetch_array($result1, $row);        
        
                                /* display stuff */



$query2 = "SELECT * FROM subs WHERE mid = '{$_SESSION['mid']}' AND rid = '{$myrow['rid']}'";

                                        $result2 = pg_exec($db, $query2);
                                        if (!$result2) { exit;}
                                
                                        $numrows2 = pg_numrows($result2);
                                        $row = 0;
                                        do
                                        {
                                                $myrow = 
pg_fetch_array($result2, $row);        
                
                                                        /* display stuff */
        
                                        $row++;
                                        }
                                        while ($row < $numrows2);
        
        
        
        
$query3 = "SELECT * FROM subs where subsid = '{$_SESSION['subsid']}' AND rid = '{$myrow['rid']}' AND responded = '1'";
        
                                        $result3 = pg_exec($db, $query3);
                                        if (!$result3) { exit;}
                                
                                        $numrows3 = pg_numrows($result3);
                                        $row = 0;
                                        do
                                        {
                                        $myrow = pg_fetch_array($result3, 
$row);        
        
                                                /* display stuff */
        
                                        $row++;
                                        }
                                        while ($row < $numrows3);....

                
                $row++;         
                }
                while ($row < $numrows1);

?>



If I may, I would like to suggest a few other changes that you might like.

first off, don't use counters, they waist cpu cycles.  Try this code out.


<?php

include("dbc.php");
if (!$db){ $_SESSION['db'] = "select-thread"; session_write_close();

// Whhhhaaaattttt........???  what is this for?
header("location: db.php");}
#
#
#
# why are you displaying anything after a header('Location ....') call?


// Build first query
$query1 = "SELECT *
           FROM   replies
           WHERE  mid = '{$_SESSION['mid']}'";
                                                        
// Execute query. if it fails, skip this block
if ( ($result1 = pg_exec($db, $query1)) !== false ) {

  // if we are here, the query worked.  Loop through results
  while ( $row1 = pg_fetch_assoc($result1) ) {

    /* display stuff */

    // Build second query
    $query2 = "SELECT *
               FROM   subs
               WHERE  mid = '{$_SESSION['mid']}'
               AND    rid = '{$row1['rid']}'";


    // Execute second query, if it fails, skip this block
    if ( ($result2 = pg_exec($db, $query2)) !== false ) {
      // If we are here, the query worked.  Loop through results
      while ( $row2 = pg_fetch_assoc($result2) ) {
        /* display stuff */
      }
    }

    // Build third query
    $query3 = "SELECT *
               FROM   subs
               WHERE  subsid = '{$_SESSION['subsid']}'
               AND    rid = '{$row1['rid']}'
               AND    responded = '1'";

    // Execute third query, if it fails, skip this block
    if ( ($result3 = pg_exec($db, $query3)) !== false ) {
      // If we are here, the query worked.  Loop through results
      while ( $row3 = pg_fetch_assoc($result3) ) {
        /* display stuff */
      }
    }
  }
}

?>

My guess is is that you don't want to actually 'exit;' the script if a query fails, you just wanted to skip displaying any data for it. I might be wrong, but I adjusted my example to factor this in.

Inquiring minds want to know. Why is it that you have a header() call with a location header that tells this script to go somewhere else, but then you display a bunch of data after the header call is sent to the client?


--- End Message ---
--- Begin Message ---
Hi Jim,

Actually, after I got the code working, I eliminated the 'exit' and skipped 
the empty query instead to the next block.

Ahh! That cryptic header relocate: 

If the db conn or code is buggy fails, it redirects to a nice page telling the 
user that the db 'Is down for maintenance' or somesuch. 

The primary reason for it: debugging -- it shows up in my logs with the conn 
that failed, and helps pinpoint problems within the code. Has saved my butt a 
few times particularly on my main site that is heavily accessing the db with 
lots of sub-code to wade through.

Thanks for the nifty advice -- code sure looks pretty now and works like a 
charm!

Regards,
Andre
(celtic)

On Wednesday 28 May 2008, Jim Lucas wrote:
<snip>

> If I may, I would like to suggest a few other changes that you might like.
>
> first off, don't use counters, they waist cpu cycles.  Try this code out.
>
>
> <?php
>
> include("dbc.php");
> if (!$db){ $_SESSION['db'] = "select-thread"; session_write_close();
>
> // Whhhhaaaattttt........???  what is this for?
> header("location: db.php");}
> #
> #
> #
> # why are you displaying anything after a header('Location ....') call?
>
>
> // Build first query
> $query1 = "SELECT *
>             FROM   replies
>             WHERE  mid = '{$_SESSION['mid']}'";
>
> // Execute query. if it fails, skip this block
> if ( ($result1 = pg_exec($db, $query1)) !== false ) {
>
>    // if we are here, the query worked.  Loop through results
>    while ( $row1 = pg_fetch_assoc($result1) ) {
>
>      /* display stuff */
>
>      // Build second query
>      $query2 = "SELECT *
>                 FROM   subs
>                 WHERE  mid = '{$_SESSION['mid']}'
>                 AND    rid = '{$row1['rid']}'";
>
>
>      // Execute second query, if it fails, skip this block
>      if ( ($result2 = pg_exec($db, $query2)) !== false ) {
>        // If we are here, the query worked.  Loop through results
>        while ( $row2 = pg_fetch_assoc($result2) ) {
>          /* display stuff */
>        }
>      }
>
>      // Build third query
>      $query3 = "SELECT *
>                 FROM   subs
>                 WHERE  subsid = '{$_SESSION['subsid']}'
>                 AND    rid = '{$row1['rid']}'
>                 AND    responded = '1'";
>
>      // Execute third query, if it fails, skip this block
>      if ( ($result3 = pg_exec($db, $query3)) !== false ) {
>        // If we are here, the query worked.  Loop through results
>        while ( $row3 = pg_fetch_assoc($result3) ) {
>          /* display stuff */
>        }
>      }
>    }
> }
>
> ?>
>
> My guess is is that you don't want to actually 'exit;' the script if a
> query fails, you just wanted to skip displaying any data for it.  I
> might be wrong, but I adjusted my example to factor this in.
>
> Inquiring minds want to know.  Why is it that you have a header() call
> with a location header that tells this script to go somewhere else, but
> then you display a bunch of data after the header call is sent to the
> client?



--- End Message ---
--- Begin Message ---
Thanks Wolf and Chris,

That did the trick -- now I just have to clean up the order a bit.

Amazing how another's view can see the problem so clearly -- I was way too 
close, what with otehr coding - should've seen it!

Regards,
Andre
(celtic)

On Wednesday 28 May 2008, Wolf wrote:
> Chris wrote:
> >>            $numrows1 = pg_numrows($result1);
> >>            $row = 0;
> >>            do
> >>            {
> >>                    $myrow = pg_fetch_array($result1, $row);
> >
> > <snip>
> >
> >>                                    $numrows2 = pg_numrows($result2);
> >>                                    $row = 0;
> >>                                    do
> >>                                    {
> >>                                            $myrow = 
> >> pg_fetch_array($result2, $row);
> >
> > You're overwriting your variables.
> >
> > $myrow from result 1 is being killed off when it gets into the $myrow
> > loop from result 2.
>
> Yeah, what Chris said!
>
> When you are looping inside another piece, make sure to change up all
> your variables.
> use a $j inside an $i, a $l inside a $k, $rowa inside a $row
>
> Woulda saved yourself a day of playing...
>
> Remember, the variable scope changes inside a function or class, but
> outside of that they pretty much run the whole length of the script.
>
> HTH,
> Wolf



--- End Message ---
--- Begin Message ---
1. URL
http://pub.qmoon.net/WMSStatus/WMS.asmx/IRadioGetCurrentPublishPoint

2. Call method

HTTP GET:
GET / WMSStatus/WMS.asmx/IRadioGetCurrentPublishPoint HTTP/1.1
Host: pub.qmoon.net

3.  return (string)

<?xml version="1.0" encoding="utf-8" ?>
<string xmlns="http://www.qmoon.net/";>mms://pub.qmoon.net/audio</string>

How can I listen to the audio stream with PHP?
Anybody some suggestions?

Thank you in advance.


-- 
Regards,
Shelley

--- End Message ---

Reply via email to