php-general Digest 6 Jun 2005 15:48:41 -0000 Issue 3497

Topics (messages 216462 through 216493):

Displaying an Outlook Calendar on a webpage using PHP
        216462 by: Justin.Baiocchi.csiro.au
        216490 by: tg-php.gryffyndevelopment.com

categories and sub categories
        216463 by: Merlin

Re: stripping html tags
        216464 by: Dotan Cohen

about the absolutely path
        216465 by: yangshiqi

Compiling PDO statically into PHP 5.0.4
        216466 by: Andreas Korthaus

linux php editor
        216467 by: Clive Zagno
        216470 by: Jack Jackson
        216485 by: Greg Donald
        216486 by: John Nichel
        216489 by: Greg Donald
        216492 by: John Nichel
        216493 by: Rory Browne

Re: replace striing éèêà
        216468 by: Jochem Maas

Re: looping through an array problem
        216469 by: Jochem Maas

PHP5 with Apache 1.3.29
        216471 by: XMG

How to submit a form that has a file included ?
        216472 by: Mário Gamito
        216473 by: Jay Blanchard
        216475 by: Mathieu Dumoulin

Implode? Explode?
        216474 by: Jack Jackson
        216482 by: Brent Baisley

Re: What is faster?
        216476 by: Mark Cain
        216477 by: Jochem Maas
        216478 by: Marek Kilimajer

Regex help
        216479 by: RaTT
        216487 by: Philip Hallstrom

PHP bug within multi. dimensional arrays?
        216480 by: Merlin
        216481 by: Matthew Weier O'Phinney
        216483 by: Richard Davey
        216484 by: Merlin
        216491 by: Merlin

headers and session
        216488 by: Alessandro Rosa

Administrivia:

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

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

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


----------------------------------------------------------------------
--- Begin Message ---
Hello all,
 
I am trying to publish an Outlook Calendar on a web page using PHP and
COM. I have managed to track down on the net some examples of how it
could be done. The most promising is the code below. However, all that
happens is that outlook.exe is started on the server, but nothing is
displayed on the web page and it just times-out.
 
I am running PHP 4.0.18 on Windows 2003 server and I have Outlook 2002
installed on the server.
Does anybody know why it doesn't work?
 
Thanks 
Justin
 
 
 
<?php 
$comobjOutlook = new COM("outlook.application") or die("Unable to
instantiate outlook");
 

//$comobjOutlook -> Activate;
 

# This is your mailbox name just like it appears in your Folders view.
It might be 'Inbox' or something else. 
$targetmailboxname = "Mailbox - Baiocchi, Justin (CSIRO IT, Armidale)";
 

# This is the folder you're looking for. In this case, I'm looking for
calendar items, but you can look for 
# any folder. You need to add another loop to look for subfolders.
Although there's probably a better 
# way, that's how I did it when I needed to get to Personal
Folders/Inbox/Subfoldername 
$targetfoldername = "Calendar"; 
 

$objNamespace = $comobjOutlook->GetNameSpace("MAPI"); 
$objFolders = $objNamespace->Folders(); 
$mailboxcount = $objFolders -> Count(); 
 

$foundmailbox = FALSE; 
for ($i=1; $i<=$mailboxcount; $i++) { 
  $folderitem = $objFolders ->Item($i); 
  if ($folderitem -> Name == $targetmailboxname) { 
    $objMailbox = $folderitem; 
    $foundmailbox = TRUE; 
  } 
} 
 

$foundcal = FALSE; 
if ($foundmailbox) { 
  $objFolders = $objMailbox->Folders(); 
  $foldercount = $objFolders -> Count(); 
 

  for ($i=1; $i<=$foldercount; $i++) { 
    $folderitem = $objFolders -> Item($i); 
    if ($folderitem -> Name == $targetfoldername) { 
      $objCalendar = $folderitem; 
      $foundcal = TRUE; 
    } 
  } 
 

  if ($foundcal) { 
    $objItems = $objCalendar->Items(); 
    $itemcount = $objItems->Count(); 
 

    for ($i=1; $i<=$itemcount; $i++) { 
      $apptitem = $objItems -> Item($i); 
      $apptstart = $apptitem -> Start(); 
      $apptend = $apptitem -> End(); 
      $apptallday = $apptitem -> AllDayEvent(); 
      $apptrecur = $apptitem -> IsRecurring(); 
      $apptsubject = $apptitem -> Subject(); 
      $apptlocation = $apptitem -> Location(); 
 

      $secondsadj = $apptstart - 14400; 
      $startadj = date("m/d/Y H:i:s", mktime(0,0,$secondsadj,1,1,1970));

 

      $secondsadj = $apptend - 14400; 
      $endadj = date("m/d/Y H:i:s", mktime(0,0,$secondsadj,1,1,1970)); 
 

      if($apptallday) { $allday = "All Day"; } else { $allday = ""; } 
      if($apptrecur) { $recurring = "Recurring"; } else { $recurring =
""; } 
 

      echo "$apptsubject @ $apptlocation\r\nFrom: $startadj To:
$endadj\r\n"; 
      if ($allday <> "" OR $recurring <> "") echo "$allday
$recurring\r\n"; 
      echo "\r\n\r\n"; 
    } 
 

  } else { 
    die ("Did not find calendar folder"); 
  } 
 

} else { 
  die("Did not find target mailbox: $targetmailboxname"); 
} 
?> 
 
 

--- End Message ---
--- Begin Message ---
That looks like some of my code.. or a derivative of my code.   For some 
reason, my PC at work here is having issues with PHP instantiating with COM so 
I can't test this, but the code you posted is conspicuously missing all the 
braces { }.  I'm guessing that's not your issue though... or else you'd be 
getting some kind of error maybe.

Anyway, here's a re-braced version of the code.   It should produce something 
when run through a web browser, but you might View Source and see what shows up 
there.

This does require Outlook to be installed on the PC that PHP is running on, as 
that's how COM works.   I never messed around with remote COM calls, but I'm 
sure there's some way to do that.

If someone wants to try this code and see if there are other issues besides the 
missing braces.  I don't see anything obviously wrong with it (besides maybe 
some sloppy programming on my part :).  I'll see about checking it when I get 
home tonight if I have time.

<?php
$comobjOutlook = new COM("outlook.application") or die("Outlook not loaded");

//$comobjOutlook -> Activate;

# This is your mailbox name just like it appears in your Folders view.
# It might be 'Inbox' or something else.
$targetmailboxname = "Mailbox - Baiocchi, Justin (CSIRO IT, Armidale)";


# This is the folder you're looking for. In this case, I'm looking for calendar
# items, but you can look for any folder. You need to add another loop to look
# for subfolders. Although there's probably a better way, that's how I did it 
when 
# I needed to get to Personal Folders/Inbox/Subfoldername
$targetfoldername = "Calendar";

$objNamespace = $comobjOutlook->GetNameSpace("MAPI");
$objFolders = $objNamespace->Folders();
$mailboxcount = $objFolders -> Count();


$foundmailbox = FALSE;
for ($i=1; $i<=$mailboxcount; $i++) {
  $folderitem = $objFolders ->Item($i);
  if ($folderitem -> Name == $targetmailboxname) {
    $objMailbox = $folderitem;
    $foundmailbox = TRUE;

    $foundcal = FALSE;
    if ($foundmailbox) {
      $objFolders = $objMailbox->Folders();
      $foldercount = $objFolders -> Count();

      for ($i=1; $i<=$foldercount; $i++) {
        $folderitem = $objFolders -> Item($i);
        if ($folderitem -> Name == $targetfoldername) {
          $objCalendar = $folderitem;
          $foundcal = TRUE;
        }
      }
    }


    if ($foundcal) {
      $objItems = $objCalendar->Items();
      $itemcount = $objItems->Count();

      for ($i=1; $i<=$itemcount; $i++) {
        $apptitem = $objItems -> Item($i);
        $apptstart = $apptitem -> Start();
        $apptend = $apptitem -> End();
        $apptallday = $apptitem -> AllDayEvent();
        $apptrecur = $apptitem -> IsRecurring();
        $apptsubject = $apptitem -> Subject();
        $apptlocation = $apptitem -> Location();

        $secondsadj = $apptstart - 14400;
        $startadj = date("m/d/Y H:i:s", mktime(0,0,$secondsadj,1,1,1970));

        $secondsadj = $apptend - 14400;
        $endadj = date("m/d/Y H:i:s", mktime(0,0,$secondsadj,1,1,1970));

        if($apptallday)  $allday = "All Day";  else  $allday = "";
        if($apptrecur)  $recurring = "Recurring";  else  $recurring = "";

        echo "$apptsubject @ $apptlocation\r\nFrom: $startadj To: $endadj\r\n";

        if ($allday <> "" OR $recurring <> "") echo "$allday $recurring\r\n";
        echo "\r\n\r\n";
      }
    } else {
      die ("Did not find calendar folder");
    }
  } else {
    die("Did not find target mailbox: $targetmailboxname");
  }
}
?>



= = = Original message = = =

Hello all,
 
I am trying to publish an Outlook Calendar on a web page using PHP and
COM. I have managed to track down on the net some examples of how it
could be done. The most promising is the code below. However, all that
happens is that outlook.exe is started on the server, but nothing is
displayed on the web page and it just times-out.
 
I am running PHP 4.0.18 on Windows 2003 server and I have Outlook 2002
installed on the server.
Does anybody know why it doesn't work?
 
Thanks 
Justin


___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

--- End Message ---
--- Begin Message ---
Hi there,

I am trying to retrieve cat and subcategories out of 2 db tables and output them via php. That seems not to be that trivial.

My goal is to have output like this:

- Languages
        : php
        : asp
- Fruites
        : apples
        : peaches

Therefore I do have a table cat and a tabel sub_cat and the values are filled into the arrays $cat[main][name] and $cat[sub][name].

Now here is my output try:

for ($i=0;$i<count($cat[main][name]);$i++){
        # output main cat
        echo $cat[main][name][$i];
                
        # output subcats which belong to this main cat
        for ($k=0;$k<count($cat[sub][name]);$k++){
                cat[sub][name][$k];
        }
};

I am lost here and could need some advice. Any help is appreciated.

Merlin

--- End Message ---
--- Begin Message ---
On 6/6/05, Chris Shiflett <[EMAIL PROTECTED]> wrote:
> Dotan Cohen wrote:
> > IF you know every single tag that exists! And being how I only wanted
> > to remove four of them, the list of 'what to remove' is so much more
> > compact than the 'leave those' list!
> 
> For what purpose are you wanting to remove tags? If this is for data
> that you plan to send to the client, then your approach is poor.
> 
> Your reasoning is exactly why you should never try to guess which tags
> to remove - you're almost certain to forget something. This is why so
> many people create PHP applications with security vulnerabilities.
> 
> If I've misunderstood your intent, then perhaps your approach is fine,
> but I wanted to point out the risk in your approach.
> 
> Chris
> 
> P.S. You should never modify invalid data in order to make it valid.
> Thus, I think strip_tags() is also a poor approach and not something I
> ever recommend using. Filtering input and escaping output are the best
> practices.
> 
> --
> Chris Shiflett
> Brain Bulb, The PHP Consultancy
> http://brainbulb.com/
> 

I am trying to access my local pop3 mail via wap. When I get home I
download the messages, but while away I need access to them. I am
trying to strip those tags from html mails so that they will display
in my wap browser.

Dotan
http://lyricslist.com/lyrics/pages/artist_albums.php/238/Guns%20N'%20Roses
Guns N' Roses Lyrics

--- End Message ---
--- Begin Message ---
I have a php application (let's call it app A) which is developed separated
in a test domain name, like http://testa.xxx.com <http://testa.xxx.com/> /.

But now I have to move it to another app (called B) using
http://testb.xxx.com <http://testb.xxx.com/> /, and the app A becomes just a
subsystem of app B.

The access url is changed to http://testb.xxx.com/a/.

Then I meet a problem that the app A 's links, the path and other elements
in it are set like '/Main.php', '/art/logo.gif' by an absolutely path.

The app A is very independent and I do not want to disperse it to app B.

So how can I get this effect: when the user input the url, '
http://testb.xxx.com/a/ ', the app A will work fine?

Can I just modify some configuration about yapache to fit this requirement?

 

 

 

 

 

 

 

Best regards,

Yang Shiqi

 

 

 

 


--- End Message ---
--- Begin Message ---
Hi!

I would like to compile PDO + PDO_sqlite statically into PHP 5.0.4. First I downloaded PDO-0.3.tgz and PDO_SQLITE-0.3.tgz and extracted them to /my/phpsrcdir/ext. I renamed the directories from "PDO-0.3" to "pdo" and from "PDO_SQLITE-0.3" to "pdo_sqlite".

I tried to follow these instructions: http://www.php.net/manual/en/install.pecl.static.php

so from /my/phpsrcdir I executed:

./buildconf --force

But after this I tried

./configure --help | grep -i pdo

without any results.

So I did not know which ./configure parameters where necessary, so I extracted these .tgz-files to another location (not in /my/phpsrcdir) and used phpize to find out which ./configure parameters I need. So I found out that I have to use

--enable-pdo --with-pdo-sqlite

I did not expect it to work, but I tried to execute the following ./configure command:

./configure \
  --prefix=/my/phpbindir/ \
  --enable-pdo \
  --with-pdo-sqlite \
  --enable-memory-limit

It did not fail, but after make && make install there is no pdo-support compiled in.

What is going wrong here? What can I do?


kind regards
Andreas

--- End Message ---
--- Begin Message --- what php GUI editors do you recommend. Ive used bluefish before, any other recommendations, thanks

clive

--- End Message ---
--- Begin Message ---


Clive Zagno wrote:
what php GUI editors do you recommend. Ive used bluefish before, any other recommendations, thanks

clive

I love Jedit http://www.jedit.com

--- End Message ---
--- Begin Message ---
On 6/6/05, Clive Zagno <[EMAIL PROTECTED]> wrote:
> what php GUI editors do you recommend.
> any other recommendations, thanks

vim


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

--- End Message ---
--- Begin Message ---
Greg Donald wrote:
On 6/6/05, Clive Zagno <[EMAIL PROTECTED]> wrote:

what php GUI editors do you recommend.
any other recommendations, thanks


vim

You newbies and your fancy editors. Back in my day, you got vi, and you were happy with it. ;)

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
On 6/6/05, John Nichel <[EMAIL PROTECTED]> wrote:
> You newbies and your fancy editors.  Back in my day, you got vi, and you
> were happy with it.  ;)

# dd if=/dev/tty of=/dev/hda1


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

--- End Message ---
--- Begin Message ---
Greg Donald wrote:
On 6/6/05, John Nichel <[EMAIL PROTECTED]> wrote:

You newbies and your fancy editors.  Back in my day, you got vi, and you
were happy with it.  ;)


# dd if=/dev/tty of=/dev/hda1

Now we just need the punch card people to speak up.

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
Cut the red, connect the blue, and green..............

In seriousness though I like vim, and Kate.

On 6/6/05, John Nichel <[EMAIL PROTECTED]> wrote:
> Greg Donald wrote:
> > On 6/6/05, John Nichel <[EMAIL PROTECTED]> wrote:
> >
> >>You newbies and your fancy editors.  Back in my day, you got vi, and you
> >>were happy with it.  ;)
> >
> >
> > # dd if=/dev/tty of=/dev/hda1
> 
> Now we just need the punch card people to speak up.
> 
> --
> John C. Nichel
> ÜberGeek
> KegWorks.com
> 716.856.9675
> [EMAIL PROTECTED]
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

--- End Message ---
--- Begin Message ---
John Taylor-Johnston wrote:
Can someone show me how to get rid of international characters in $string? Is there a function already made?

the acute/grave accents on the chars are called 'diacritics'

You cannot use accented characters in a name reference : <a name="montréal">.
I guess this below is a start. Is there a better way?
John

http://ca.php.net/manual/en/function.str-replace.php
$string = "àâéèç";
|$find = array("à", "â", "é", "è", "ç");
||$||replacewith|| = array("a", "a", "e", "e", "c");||
||||$onlyconsonants = str_replace($vowels, $replacewith, $string);


<?php
// you could do something like:

function getUndiacritical($word)
{

$base_drop_char_match = array('^', '$', '&', '(', ')', '<', '>', '`', '\'', '"', '|', ',', '@', '_', '?', '%', '-', '~', '+', '.', '[', ']', '{', '}', ':', '\\', '/', '=', '#', '\'', ';', '!'); $base_drop_char_replace = array(' ', ' ', ' ', ' ', ' ', ' ', ' ', '', '', ' ', ' ', ' ', ' ', '', ' ', ' ', '', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' , ' ', ' ', ' ', ' ', ' ', ' ');

$xtr_drop_char_match = array('à', 'â', 'ä', 'æ', 'è', 'ê', 'ì', 'î', 'ð', 'ò', 'ô', 'ö', 'ø', 'ú', 'ü', 'ß', 'á', 'ã', 'å', 'ç', 'é', 'ë', 'í', 'ï', 'ñ', 'ó', 'õ', 'ù', 'û', 'ý', 'ÿ'); $xtr_drop_char_replace = array('a', 'a', 'a', 'a', 'e', 'e', 'i', 'i', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 's', 'a', 'a', 'a', 'c', 'e', 'e', 'i', 'i', 'n', 'o', 'o', 'u', 'u', 'y', 'y');

$drop_char_match   = array_merge( $base_drop_char_match, $xtr_drop_char_match );
$drop_char_replace = array_merge( $base_drop_char_replace, 
$xtr_drop_char_replace );

return str_replace($drop_char_match, $drop_char_replace, $word);

}

// alternatively


function getUndiacritical2($word)
{

$base_drop_char_match = array('^', '$', '&', '(', ')', '<', '>', '`', '\'', '"', '|', ',', '@', '_', '?', '%', '-', '~', '+', '.', '[', ']', '{', '}', ':', '\\', '/', '=', '#', '\'', ';', '!'); $base_drop_char_replace = array(' ', ' ', ' ', ' ', ' ', ' ', ' ', '', '', ' ', ' ', ' ', ' ', '', ' ', ' ', '', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' , ' ', ' ', ' ', ' ', ' ', ' ');

$xtr_drop_char_match = array('à', 'â', 'ä', 'æ', 'è', 'ê', 'ì', 'î', 'ð', 'ò', 'ô', 'ö', 'ø', 'ú', 'ü', 'ß', 'á', 'ã', 'å', 'ç', 'é', 'ë', 'í', 'ï', 'ñ', 'ó', 'õ', 'ù', 'û', 'ý', 'ÿ'); $xtr_drop_char_replace = array('a', 'a', 'a', 'a', 'e', 'e', 'i', 'i', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 's', 'a', 'a', 'a', 'c', 'e', 'e', 'i', 'i', 'n', 'o', 'o', 'u', 'u', 'y', 'y');

$drop_char_match   = join('',array_merge( $base_drop_char_match, 
$xtr_drop_char_match ));
$drop_char_replace = join('',array_merge( $base_drop_char_replace, 
$xtr_drop_char_replace ));

return strtr($drop_char_match, $drop_char_replace, $word);

}


?>

I doubt either of these funcs is perfect but it hopefully gives you a clue in 
the right
redirection.

rgds,
Jochem


|


--- End Message ---
--- Begin Message ---
Jack Jackson wrote:
Forgive me if this comes twice: my ISP had a service blackout for three hours and I don't know what went:


If my last post read (and I see that it did) that I was defending myself
as opposed to falling ALL OVER my sword, I apologize: allow me to be clear:

No, you're all correct and M. Sokolewicz doubly so: I had
unintentionally selected fields from the wrong table for no reason other
than  lack of sleep coupled with lack of experience and a desperation to
try to understand

The problem was that I was pulling data in a manner both useless and
complex from a thoroughly unnecessary table (I could tell you all why
but you'll all just laugh at me more)

I am grateful for all the help everyone has offered up to now and hope I
did not offend  - I was trying in my last post to indicate that I  was
an idiot, and it appears I've come off as arrogant. I promise it was not
my intent!

don't worry - I got the idea that maybe there was some confusion
- nothing else. oh and I don't think anyone is/will laugh at you
(well most of us won't ;-/), we have all been 'there' :-)

so all is well.



[Then I wrote::]

Ah. I just remembered one reason I had done it involving the art_id field:

I have more publishers in the db than are currently associated with artworks. I don't want a publisher to appear unless there is at least one image associated with it. So I did this to avoid having people see a link to the Sneezy Acres Tribune only to arrive at the next page and see, "There are no images associated with this publisher."



Jochem Maas wrote:

Jack Jackson wrote:



M. Sokolewicz wrote:

Jack Jackson wrote:

Thanks for all the replies. Jochem, thank you for this code, which will take me all night to understand (though I bet it works). I also note that SELECT DISTINCT worked here, too

Also as many of you noticed before me, the art_id was in there as a fly in the ointment.




by that statement I ment the exact same thing Jochem ment in his 2nd part; I have NO idea why you're selecting *ANYTHING* from the arts table... it's *useless* if you don't need the data...




Er, yes, that was what I meant: I had unintentionally included that bit.Thank you for your help.


Er, Jack - your original query was:

SELECT art.art_id,art.publisher_id,publisher.publisher_name,
FROM art
LEFT JOIN publisher
ON publisher.publisher_id=art.publisher_id

which is a selection on the art table... ( with a typo)
if you did:

SELECT art.publisher_id,publisher.publisher_name
FROM art
LEFT JOIN publisher
ON publisher.publisher_id=art.publisher_id

nothing would change. and if you did:

SELECT publisher.publisher_id,publisher.publisher_name
publisher

i.e. not 'unintentionally' selecting from the arts table.
then you would not have had a problem in the first place?!

I think I'm missing something ;-)



--- End Message ---
--- Begin Message --- I am trying to build Apache 1.3.29 on Fedora to use with mod_ssl and PHP5. After having built this all with no apparent problems I see this error message in the Apache error_log on startup:

[Mon Jun 6 06:32:21 2005] [warn] Loaded DSO libexec/libphp5.so uses plain Apache 1.3 API,
   this module might crash under EAPI! (please recompile it with -DEAPI)

Ok, so I went back and changed the configuration for mod_ssl (mod_ssl-2.8.16-1.3.29) so that it would configure Apache to use the -DEAPI switch, e.g.:

./configure \
       --with-apache=../apache_1.3.29 \
       --with-ssl=../openssl-0.9.7c \
       --prefix=/usr/local/apache \
       --enable-module=so \
       --disable-rule=EAPI

That seemed to work ok, and when I make Apache I see lines like this for gcc so sure looks like the switch is being applied:

   gcc -c  -I./os/unix -I./include   -DLINUX=22 -DMOD_SSL=208116
   -DUSE_HSREGEX -DEAPI `./apaci` modules.c

Then I re-installed PHP5 and configured it again to use this Apache, but I am still seeing this warning in the startup log. So I was hoping that someone here perhaps has seen this error before and has a clue as what it is about? :)

Thanks in advance,

Lawrence Kennon
www.theNewAgeSite.com

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

I want to have a form with text fields and a "browse field" for
uploading a file.

Let's say i have a form with just two fields:

<form name="form1" method="post" action="action.php">
  <tr>
   <td>
    Employee:<br />
    Name: <input name="name" type="text" id="name" size="50">
   </td>
  </tr>

 Employee File (a .doc):
  Now, i want here a browse button, so users when clicking on it trigers
the os "File Open" box to choose the file to upload.

</form>

My question is: what is the code i need in the form ?
And the <form> tag, is it allright like it is ?

Thank you in advance.

Warm regards,
Mário Gamito

--- End Message ---
--- Begin Message ---
[snip]
I want to have a form with text fields and a "browse field" for
uploading a file.
...
  Now, i want here a browse button, so users when clicking on it trigers
the os "File Open" box to choose the file to upload.
...
My question is: what is the code i need in the form ?
And the <form> tag, is it allright like it is ?
[/snip]

Read this section, http://us4.php.net/manual/en/features.file-upload.php it has 
examples.

--- End Message ---
--- Begin Message ---
Jay Blanchard wrote:
[snip]
I want to have a form with text fields and a "browse field" for
uploading a file.
...
  Now, i want here a browse button, so users when clicking on it trigers
the os "File Open" box to choose the file to upload.
...
My question is: what is the code i need in the form ?
And the <form> tag, is it allright like it is ?
[/snip]

Read this section, http://us4.php.net/manual/en/features.file-upload.php it has 
examples.

Never tried this?

<input type="file" name="wathever" size="100">

;)

--- End Message ---
--- Begin Message ---
Hi all,
I'm trying to fetch similar things - in this case, rows which share a series ID no - and bring them into an array and display them grouped by what makes them similar (in this case, series id). I looked at implode and explode which seem wrong for this - the only separator I can see is that they're each in a table cell.

The result of my query returns something like:

art_id   series_id     art_title            series_name
2       1              Weddings 2004        Summer Special
4       1              Summer In The City   Summer Special
5       2              Bags of NY           Op-Art
7       2              Dogs of NY           Op-Art


I'd like to create a list of links to each art_id grouped together as series, href code obviously not complete but demonstrative:

<p>Summer Special<br />
<a href='2'>Weddings 2004</a> | <a href='4'>Summer In The City</p>

<p>Op-Art<br />
<a href='5'>Bags of NY</a> | <a href='7'>Dogs of NY</p>


?

Thanks in advance,
Jack

--- End Message ---
--- Begin Message --- You're close, but you need to group your data on the series_id first. You can do that by looping through your array and creating another array using series_id as the array key. You'll end up with a list of arrays named after the series_id.

foreach( $result_set as $result_item ) {
        //Add an array item to the series_id slot of the grouped_result array
$grouped_result[ $result_item['series_id'] ][] = array('id'=>$result_items['art_id'], 'title'=>$result_item['art_title']);
}

Now you have your data grouped by series_id. Each item of the grouped_result array will contain one or more arrays which contain the art_id and art_title.

If you are not familiar with multidimensional arrays, this may be a little confusing.



On Jun 6, 2005, at 8:32 AM, Jack Jackson wrote:

Hi all,
I'm trying to fetch similar things - in this case, rows which share a series ID no - and bring them into an array and display them grouped by what makes them similar (in this case, series id). I looked at implode and explode which seem wrong for this - the only separator I can see is that they're each in a table cell.

The result of my query returns something like:

art_id   series_id     art_title            series_name
2       1              Weddings 2004        Summer Special
4       1              Summer In The City   Summer Special
5       2              Bags of NY           Op-Art
7       2              Dogs of NY           Op-Art


I'd like to create a list of links to each art_id grouped together as series, href code obviously not complete but demonstrative:

<p>Summer Special<br />
<a href='2'>Weddings 2004</a> | <a href='4'>Summer In The City</p>

<p>Op-Art<br />
<a href='5'>Bags of NY</a> | <a href='7'>Dogs of NY</p>


?

Thanks in advance,
Jack

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


--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577

--- End Message ---
--- Begin Message ---
I see your point about including the timing code in the calculation itself
and while it does add time to the process, he is not just timing this
code -- he is timing this code against another.  Meaning we don't want to
know "How fast is this code?" per se -- we want to know "Which is faster?"
So, arguably from the faster point of view, as long as the time mech is in
both tests, the question will be answered with a degree of certainty.  From
the days of my boyhood, even if the race route were "two times around the
big oak tree," the faster runner would still win the race.

Question for you, please:

In your post you say:

> time. For example, using something like ab will let you test your code
> in its raw form - without the timing and looping.

What is ab?  I am somewhat limited in my depth and scope of php and so I
have never seen this before.  Care to point me in a direction where I could
learn more?

Mark Cain




----- Original Message -----
From: "Chris Shiflett" <[EMAIL PROTECTED]>
To: "Mark Cain" <[EMAIL PROTECTED]>
Cc: "Andy Pieters" <[EMAIL PROTECTED]>; <php-general@lists.php.net>
Sent: Sunday, June 05, 2005 9:56 PM
Subject: Re: [PHP] What is faster?


> Mark Cain wrote:
> > I checked the first expression with 1,000 iterations and it
> > took 0.00745 seconds.
> >
> > Here is the code I used.
>
> [snip]
>
> > $start1 = vsprintf('%d.%06d', gettimeofday());
>
> Although many would argue that it's pointless to worry over such small
> details (and they have valid arguments), it's better to construct your
> benchmark so that the timing mechanism impacts your code as little as
> possible.
>
> Although consistency is difficult to achieve without some effort, you
> can at least get your timing mechanism out of the code that you want to
> time. For example, using something like ab will let you test your code
> in its raw form - without the timing and looping.
>
> I also dislike unit tests that are part of the code they're meant to
> test. :-)
>
> Hope that helps.
>
> Chris
>
> --
> Chris Shiflett
> Brain Bulb, The PHP Consultancy
> http://brainbulb.com/
>
>

--- End Message ---
--- Begin Message ---
Mark Cain wrote:
I see your point about including the timing code in the calculation itself
and while it does add time to the process, he is not just timing this
code -- he is timing this code against another.  Meaning we don't want to
know "How fast is this code?" per se -- we want to know "Which is faster?"
So, arguably from the faster point of view, as long as the time mech is in
both tests, the question will be answered with a degree of certainty.  From
the days of my boyhood, even if the race route were "two times around the
big oak tree," the faster runner would still win the race.

Question for you, please:

In your post you say:


time. For example, using something like ab will let you test your code
in its raw form - without the timing and looping.


What is ab?  I am somewhat limited in my depth and scope of php and so I
have never seen this before.  Care to point me in a direction where I could
learn more?

apache benchmark, try:

> man ab

on your local linux cmd line (assuming you have apache installed)


Mark Cain




----- Original Message -----
From: "Chris Shiflett" <[EMAIL PROTECTED]>
To: "Mark Cain" <[EMAIL PROTECTED]>
Cc: "Andy Pieters" <[EMAIL PROTECTED]>; <php-general@lists.php.net>
Sent: Sunday, June 05, 2005 9:56 PM
Subject: Re: [PHP] What is faster?



Mark Cain wrote:

I checked the first expression with 1,000 iterations and it
took 0.00745 seconds.

Here is the code I used.

[snip]


$start1 = vsprintf('%d.%06d', gettimeofday());

Although many would argue that it's pointless to worry over such small
details (and they have valid arguments), it's better to construct your
benchmark so that the timing mechanism impacts your code as little as
possible.

Although consistency is difficult to achieve without some effort, you
can at least get your timing mechanism out of the code that you want to
time. For example, using something like ab will let you test your code
in its raw form - without the timing and looping.

I also dislike unit tests that are part of the code they're meant to
test. :-)

Hope that helps.

Chris

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/





--- End Message ---
--- Begin Message ---
Mark Cain wrote:
I see your point about including the timing code in the calculation itself
and while it does add time to the process, he is not just timing this
code -- he is timing this code against another.  Meaning we don't want to
know "How fast is this code?" per se -- we want to know "Which is faster?"

You want to also know which one parses faster

--- End Message ---
--- Begin Message ---
Hi Guys, 

I am currently creating a once off text parser for a rather large
document that i need to strip out bits of information on certain
lines.

The line looks something like :


"Adress line here, postcode, country Tel: +27 112233665 Fax: 221145221
Website: http://www.urlhere.com E-Mail: [EMAIL PROTECTED] TAGINCAPS: CAPS
RESPONSE Tag2: blah"


I need to retreive the text after each marker i.e Tel: Fax: E-Email:
TAGINCAPS: ...

I have the following regex /Tel:\s*(.[^A-z:]+)/ and
/Fax:\s*(.[^A-z:]+)/ all these work as expected and stop just before
the next Tag. However I run into hassels  around the TAGINCAPS as the
response after it is all in caps and i cant get the Regex to stop just
before the next tag: which may be either all caps or lowercase.

I cant seem to find the regex that will retreive all chartures just
before a word with a :  regalrdless of case.

I have played around with the regex coach but still seem to be comming
up short so i thought i would see if anybody can see anything i might
have missed.

any help most appreciated. 

Regards 
Jarratt

--- End Message ---
--- Begin Message ---
I am currently creating a once off text parser for a rather large
document that i need to strip out bits of information on certain
lines.

The line looks something like :


"Adress line here, postcode, country Tel: +27 112233665 Fax: 221145221
Website: http://www.urlhere.com E-Mail: [EMAIL PROTECTED] TAGINCAPS: CAPS
RESPONSE Tag2: blah"

I need to retreive the text after each marker i.e Tel: Fax: E-Email:
TAGINCAPS: ...

I have the following regex /Tel:\s*(.[^A-z:]+)/ and
/Fax:\s*(.[^A-z:]+)/ all these work as expected and stop just before
the next Tag. However I run into hassels  around the TAGINCAPS as the
response after it is all in caps and i cant get the Regex to stop just
before the next tag: which may be either all caps or lowercase.

I cant seem to find the regex that will retreive all chartures just
before a word with a :  regalrdless of case.

I have played around with the regex coach but still seem to be comming
up short so i thought i would see if anybody can see anything i might
have missed.

Any reason you can't match everything from TAGINCAPS through the end of the line, then once you have that stored in a string, split it on ":"'s to extract the pieces you want? Even elements would be the tag, odd would be the value...

just a thought.

--- End Message ---
--- Begin Message ---
Hi there,

I am outputting an multidim. array. That works fine, except one thing. The first letter of the value inside dimension 1 always gets printed.

For example:

I fill the arrays:
while ($row = mysql_fetch_object($result)){             
        $cat[$row->main_id][name]            = $row->main_name;   
        $cat[$row->main_id][$row->sub_id][name] = $row->sub_name;               
       
}

Then I output them:
foreach ($cat AS $maincat){
        echo $maincat[name].':';
        foreach($maincat AS $subcat){
                echo $subcat[name].$br;
        }
        echo $br;
}

Which does result in:

Europe:E
Germany
UK

North America:N
US
CA

As you can see I get the extra letters N and E. Is this an php error or did I do something wrong?

Thanx for any hint,

Merlin

--- End Message ---
--- Begin Message ---
* Merlin <[EMAIL PROTECTED]>:
> Hi there,
>
> I am outputting an multidim. array. That works fine, except one thing. The 
> first 
> letter of the value inside dimension 1 always gets printed.
>
> For example:
>
> I fill the arrays:
> while ($row = mysql_fetch_object($result)){           
>       $cat[$row->main_id][name]               = $row->main_name;      
>       $cat[$row->main_id][$row->sub_id][name] = $row->sub_name;               
>         
> }

First off, if you're creating associative arrays, you should quote the
keys:

    $cat[$row->main_id]['name'] = $row->main_name;

If you don't do so, PHP assumes you're using a constant value for the
key name.

> Then I output them:
> foreach ($cat AS $maincat){
>       echo $maincat[name].':';

Quote your keys!

>       foreach($maincat AS $subcat){

You do realize that the above will also loop over the index 'name',
right?...

>               echo $subcat[name].$br;

and since it does, the first element in that array is 'name', which
isn't an array, but a string. Since the 'name' constant isn't defined,
it will interpret that as 'true', or 1, and so it takes the first
character of that string.

>       }
>       echo $br;
> }
>
> Which does result in:
>
> Europe:E
> Germany
> UK
>
> North America:N
> US
> CA
>
> As you can see I get the extra letters N and E. Is this an php error or did I 
> do 
> something wrong?

So, what you should probably do is create an additional layer in your
multi-dimensional array for the subcategories, and have it of the form
sub_id => sub_name:

        $cat[$row->main_id]['subs'][$row->sub_id] = $row->sub_name;     

Then loop over that:

    foreach ($cat as $main_cat) {
        echo $maincat['name'] . ":\n";
        foreach ($maincat['subs'] as $sub_id => $sub_name) {
            echo "$sub_name$br"; // could also use $sub_id here if
                                 // desired
        }
    }

-- 
Matthew Weier O'Phinney           | WEBSITES:
Webmaster and IT Specialist       | http://www.garden.org
National Gardening Association    | http://www.kidsgardening.com
802-863-5251 x156                 | http://nationalgardenmonth.org
mailto:[EMAIL PROTECTED]         | http://vermontbotanical.org

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

Monday, June 6, 2005, 2:51:39 PM, you wrote:

M> while ($row = mysql_fetch_object($result)){
M>         $cat[$row->main_id][name]               = $row->main_name;
M>         $cat[$row->main_id][$row->sub_id][name] =
M> $row->sub_name;                       
M> }

Quote array keys.. ALWAYS quote them:

$cat[$blah]['name'] = $whatever

Otherwise PHP will think [name] is trying to use a constant and
substitute a value accordingly.

M> foreach ($cat AS $maincat){
M>         echo $maincat[name].':';
M>         foreach($maincat AS $subcat){
M>                 echo $subcat[name].$br;
M>         }
M>         echo $br;
M> }

M> As you can see I get the extra letters N and E. Is this an php
M> error or did I do something wrong?

You did something wrong ;) If you don't quote the array keys it'll
assume a constant, which in turn would assume a 1 which will give you
the first character of the string.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

--- End Message ---
--- Begin Message ---
Richard Davey wrote:
Hello Merlin,

Monday, June 6, 2005, 2:51:39 PM, you wrote:

M> while ($row = mysql_fetch_object($result)){
M>         $cat[$row->main_id][name]               = $row->main_name;
M>         $cat[$row->main_id][$row->sub_id][name] =
M> $row->sub_name; M> }

Quote array keys.. ALWAYS quote them:

$cat[$blah]['name'] = $whatever

Otherwise PHP will think [name] is trying to use a constant and
substitute a value accordingly.

M> foreach ($cat AS $maincat){
M>         echo $maincat[name].':';
M>         foreach($maincat AS $subcat){
M>                 echo $subcat[name].$br;
M>         }
M>         echo $br;
M> }

M> As you can see I get the extra letters N and E. Is this an php
M> error or did I do something wrong?

You did something wrong ;) If you don't quote the array keys it'll
assume a constant, which in turn would assume a 1 which will give you
the first character of the string.

Best regards,

Richard Davey

Hi Richard,

that sounds absolutly plausible and I now qoted it the way you recommended. However I do get the same result. Still the first letter.

Any other ideas?

Thank you in advance,
Merlin

--- End Message ---
--- Begin Message ---
Matthew Weier O'Phinney wrote:
* Merlin <[EMAIL PROTECTED]>:

Hi there,

I am outputting an multidim. array. That works fine, except one thing. The first letter of the value inside dimension 1 always gets printed.

For example:

I fill the arrays:
while ($row = mysql_fetch_object($result)){             
        $cat[$row->main_id][name]            = $row->main_name;   
        $cat[$row->main_id][$row->sub_id][name] = $row->sub_name;               
       
}


First off, if you're creating associative arrays, you should quote the
keys:

    $cat[$row->main_id]['name'] = $row->main_name;

If you don't do so, PHP assumes you're using a constant value for the
key name.


Then I output them:
foreach ($cat AS $maincat){
        echo $maincat[name].':';


Quote your keys!


        foreach($maincat AS $subcat){


You do realize that the above will also loop over the index 'name',
right?...


                echo $subcat[name].$br;


and since it does, the first element in that array is 'name', which
isn't an array, but a string. Since the 'name' constant isn't defined,
it will interpret that as 'true', or 1, and so it takes the first
character of that string.


        }
        echo $br;
}

Which does result in:

Europe:E
Germany
UK

North America:N
US
CA

As you can see I get the extra letters N and E. Is this an php error or did I do something wrong?


So, what you should probably do is create an additional layer in your
multi-dimensional array for the subcategories, and have it of the form
sub_id => sub_name:

        $cat[$row->main_id]['subs'][$row->sub_id] = $row->sub_name;    

Then loop over that:

    foreach ($cat as $main_cat) {
        echo $maincat['name'] . ":\n";
        foreach ($maincat['subs'] as $sub_id => $sub_name) {
            echo "$sub_name$br"; // could also use $sub_id here if
                                 // desired
        }
    }


This is very helpful and does work. However I did not understand it completley. What if I want to add another value, for example name2 or name3.
It looks like this example is limited to id and name.
Could I just add:
$cat[$row->main_id]['subs'][$row->sub_id] = $row->name2;                       

Guess not. Can you tell me how to add other fields to the array?

Thank you in advance, Merlin

--- End Message ---
--- Begin Message ---
Hi to all,

I got a problem while storing session variables.

<?php
session_start();
header( "Cache-control: private" );

require_once("config.inc.php");

////////////////////////////////////////////////////////////
$_SESSION['session_psw'] = $_POST['txtPassword'];
$_SESSION['session_user'] = $_POST['txtIdUtente'];

////////////////////////////////////////////////////////////

$PHPcmd = $GLOBALS['gestionale_path_name']."test/2.php" ;

header( "Location: ".$PHPcmd );

?>

After the call to header(...), the values of session variables are lost.

I think I should fix this up with some settings in my php.ini

Could you help me, please?

Alessandro Rosa

--- End Message ---

Reply via email to