php-general Digest 28 Nov 2002 23:44:52 -0000 Issue 1732

Topics (messages 126398 through 126442):

rewrite urls with preg_replace
        126398 by: Dieter Koch
        126417 by: liljim
        126418 by: John W. Holmes

Re: controlling ownership on file uploads ...
        126399 by: Marek Kilimajer

Re: Bad File Mode?
        126400 by: Marek Kilimajer
        126402 by: Ernest E Vogelsinger

Re: **** Converting dynamic webpages into static HTML pages
        126401 by: Marek Kilimajer

Re: printing screen without the print dialog
        126403 by: Marek Kilimajer

Bizarreness with htmlentities() and other things
        126404 by: James Coates
        126410 by: Rich Gray
        126412 by: James Coates

Re: session problems again
        126405 by: Marek Kilimajer

Re: editing .htaccess / .htpasswrd
        126406 by: Mika Tuupola
        126407 by: James Coates

String function
        126408 by: Shaun
        126409 by: Marco Tabini

Re: PHP 4.3.0RC2 released
        126411 by: Vadim Tkachenko

Re: echo'ing array contents through reference variable ... why doesn't this work???
        126413 by: -<[ Rene Brehmer ]>-

Re: echo'ing array contents through reference variable
        126414 by: -<[ Rene Brehmer ]>-

mysql, php, checkbox
        126415 by: Adrian Partenie
        126416 by: John W. Holmes

Re: Password Script
        126419 by: Bobby Patel

2D Array
        126420 by: Khalid El-Kary

Re: dynamic arraynames
        126421 by: Floyd Baker

Re: [PHP-DB] Help with date
        126422 by: Aaron Wolski

Multidimensional array
        126423 by: Mako Shark

Hello ! How to write a programme in PHP which executes a routine at a given time ?
        126424 by: Jonathan
        126425 by: Jon Haworth

Detecting email bounces sent by the mail function?
        126426 by: Ade Smith
        126430 by: DL Neil
        126432 by: Marek Kilimajer
        126434 by: Michael Sims
        126437 by: scott

Multidimensional arrays (more and more...)
        126427 by: Mako Shark
        126428 by: Marek Kilimajer
        126431 by: Mako Shark
        126439 by: Mako Shark
        126440 by: Matt Vos

File handling
        126429 by: Jeff

Postnuke ---   Meta keywords and title different for all the pages...
        126433 by: Manoj Nahar

Help with the PHP
        126435 by: Ted Frank
        126438 by: Hatem Ben

Re: [PHP-DEV] Parse search string a la Google  (Regular expression?)
        126436 by: Benny Rasmussen

session_name() - Question
        126441 by: Juerg Zgraggen

help with session variables
        126442 by: Thomas Goeminne

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 ---
Hi to all the PHP-Fans out there,

i have a syntax-problem with the folowing preg_replace command:

$returnString = preg_replace("/(href=\")(.+?)(\")/is",
preg_quote("\\1".ebLinkEncode(."\\2".)."\\3"), $returnString);

i'm trying to call my own function within a preg_replace function and it
won't work.
any ideas ? it seems to me, that the quoting is incorrect, but i'm not
shure, why it is incorrect,
especially because i use preg_quote() ...

thanks in advance for some hints !

best regards
[EMAIL PROTECTED]





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

You need to use the 'e' modifier as well as 'is' in your pattern. Have a
look in the manual, here:

http://www.php.net/manual/en/pcre.pattern.modifiers.php

"If this modifier is set, preg_replace() does normal substitution of
backreferences in the replacement string, evaluates it as PHP code, and uses
the result for replacing the search string."

Also look here:
http://www.php.net/manual/en/function.preg-replace.php

And check the "Example 2. Using /e modifier" part.

Hope that helps ;)

James


"Dieter Koch" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi to all the PHP-Fans out there,
>
> i have a syntax-problem with the folowing preg_replace command:
>
> $returnString = preg_replace("/(href=\")(.+?)(\")/is",
> preg_quote("\\1".ebLinkEncode(."\\2".)."\\3"), $returnString);
>
> i'm trying to call my own function within a preg_replace function and it
> won't work.
> any ideas ? it seems to me, that the quoting is incorrect, but i'm not
> shure, why it is incorrect,
> especially because i use preg_quote() ...
>
> thanks in advance for some hints !
>
> best regards
> [EMAIL PROTECTED]
>
>
>
>
>


--- End Message ---
--- Begin Message ---
> Hi to all the PHP-Fans out there,
> 
> i have a syntax-problem with the folowing preg_replace command:
> 
> $returnString = preg_replace("/(href=\")(.+?)(\")/is",
> preg_quote("\\1".ebLinkEncode(."\\2".)."\\3"), $returnString);
> 
> i'm trying to call my own function within a preg_replace function and
it
> won't work.
> any ideas ? it seems to me, that the quoting is incorrect, but i'm not
> shure, why it is incorrect,
> especially because i use preg_quote() ...

Take a look at preg_replace_callback().

http://www.php.net/manual/en/function.preg-replace-callback.php

---John Holmes...


--- End Message ---
--- Begin Message --- Besides what was said before, you don't even need to delete it, it will be deleted when your script is done.
If you want to keep it, you have to move it elsewhere.

Kenn Murrah wrote:

Greetings.

I've written a simple form to allow my clients to upload files to me, and it
works fine EXCEPT that the uploaded file is owned by "www" and I while I can
read the file, I don't have the necessary permissions to delete it when done
...

Since this site is being hosted elsewhere, is there a way I can control
ownership so that I can delete the file? I've written my ISP/web hoster and
received no response -- usually that's their subtle way of telling me I
should ask the PHP quiestion here :-)

Any and all help would be appreciated.

Thanks,

kenn





--- End Message ---
--- Begin Message --- You can stat (get filesize, modification time, permissions) only local files - download it first and then get its filesize if you need it.

Steve Keller wrote:

I'm still trying to get a file posted to another server, but I seem to have run across an odd snag, and I was hoping someone can point out where I've gone wrong. Here's the code:

<?
$data = "mtype=XMLDOC&outfile=true";
$dataFile = "http://www.healthtvchannel.org/courses/pay/data/test.xml";;
$fileSize = filesize($dataFile);
$fp = fopen($dataFile, "rb");
$strFile = fread($fp, $fileSize);
fclose($fp);

$osbURL="https://partners.netledger.com/SmbXml";;

$ch = curl_init();
$res = curl_setopt($ch, CURLOPT_POST, 1);
echo "Set Post: ".$res;
$res = curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
echo "<br />Set Follow: ".$res;
$res = curl_setopt($ch, CURLOPT_VERBOSE, 1);
echo "<br />Set Verbose: ".$res;
$res = curl_setopt($ch, CURLOPT_URL, $osbURL);
echo "<br />Set URL: ".$res;
$res = curl_setopt($ch, CURLOPT_POSTFIELDS, $data."&mediafile=".$strFile);
echo "<br />Set Postfields: ".$res;
$res = curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
echo "<br />Set ReturnTransfer: ".$res;

$result = curl_exec($ch);
curl_close($ch);
echo $result;
?>

What I'm getting is

Warning: stat failed for http://www.healthtvchannel.org/courses/pay/data/test.xml (errno=2 - No such file or directory) in /usr/local/www/vhosts/healthtvchannel.org/htdocs/courses/pay/posttest.php on line 20

I'm positive the file exists, and if I cut and paste the URL from the error to a browser window, I can see the file. What am I doing wrong?
--
S. Keller
UI Engineer
The Health TV Channel, Inc.
(a non - profit organization)
3820 Lake Otis Pkwy.
Anchorage, AK 99508
907.770.6200 ext.220
907.336.6205 (fax)
Email: [EMAIL PROTECTED]
Web: www.healthtvchannel.org



--- End Message ---
--- Begin Message ---
At 21:05 27.11.2002, Steve Keller spoke out and said:
--------------------[snip]--------------------
>I'm still trying to get a file posted to another server, but I seem to have 
>run across an odd snag, and I was hoping someone can point out where I've 
>gone wrong. Here's the code:
>
><?
>         $data = "mtype=XMLDOC&outfile=true";
>         $dataFile = 
>"http://www.healthtvchannel.org/courses/pay/data/test.xml";;
>         $fileSize = filesize($dataFile);
>         $fp = fopen($dataFile, "rb");
>         $strFile = fread($fp, $fileSize);
>         fclose($fp);
--------------------[snip]-------------------- 

You can't stat() a remote file - filesize() only works with local filesystems.

However you do not need to know the size of the file to read it - simply do
it in chunks:
        $dataFile = "http://www.healthtvchannel.org/courses/pay/data/test.xml";;
        $fp = fopen($dataFile, "rb");
         $strFile = null;
         while ($chunk = fread($fp, 524288))  // 512 kB chunks modify as needed
              $strFile .= $chunk;
        fclose($fp);

HTH,

-- 
   >O Ernest E. Vogelsinger 
   (\) ICQ #13394035 
    ^ http://www.vogelsinger.at/
--- End Message ---
--- Begin Message --- Easy and intuitive are all the programs that allow you to download the whole website
http://download.com.com/3150-2071-0.html?tag=dir

Ron Stagg wrote:

I have an interesting challenge. I have built an online product catalog
that is driven entirely by the contents of the product database (MySQL).
The entire catalog is implemented in a single PHP script (catalog.php).
The dynamic nature of this implementation allows the catalog script to
generate hundreds of product description pages.

Now, my client has requested that I give him the ability to generate a
static version of the catalog so that he can burn it onto a CD for
distribution at trade shows. He wants the CD to be a snapshot of the
catalog. Furthermore, he wants to be able to generate this "snapshot"
frequently so that pricing info on the CD will be current. To
accommodate this, the process for generating the snapshot must be easy
and intuitive.

My plan of attack is to generate static HTML files by running the
catalog script once for each product in the database. Here is my
quandary; instead of echoing the output to a buffer for Apache to send
off to the client, I need the script to output to a file. I do not want
to write a second version of catalog.php that writes everything to file.
There must be an easier way to do this. Is there a way I can access the
output buffer that Apache sends to the client?

Any other ideas?

Thanks,

Ron



--- End Message ---
--- Begin Message ---
No, this is not possible - security restrictions

Duky Yuen wrote:

I am having this problem, I want to print something directly to my printer
without having that print dialog. What to do know? Is this possible?

Duky





--- End Message ---
--- Begin Message --- Hello!

I'm currently doing some work that requires a mySQL database of actor names. For all my actors, I have three columns; first_name, last_name and between_name. Because between_name can be written in many ways ("Peter van Wibble" or "Fred d'Angelo), and the French have a habit of writing their surnames in capitals, I wrote a little function to prepare the actor names for output:

<?
function actor_name($last,$middle,$first) {
// because we have so many different name combinations, write out a string
// that does capitalisation and the like properly (hopefully)
// ex: actor_name("ANGELO","d'","Jean-Pierre") = Jean-Pierre d'Angelo

// strtolower() everything because ucwords() doesn't work on mixed case
$last=strtolower($last);
$middle=strtolower($middle);
$first=strtolower($first);

// split hyphenated names so we can ucwords() them
if (strpos($last,"-")) {
$lasthyphen=true;
$last=ereg_replace("-"," ",$last);
} else { $lasthyphen=false; }

if (strpos($first,"-")) {
$firsthyphen=true;
$first=ereg_replace("-"," ",$first);
} else { $firsthyphen=false; }

// if the "middle" name doesn't end with an apostrophe, add a space and
// lowercase it just in case someone's mis-typed it
if (!strrpos($middle,"'")) {
$middle.=" ";
}

$last=ucwords($last);
$first=ucwords($first);

if ($lasthyphen==true) { $last=ereg_replace(" ","-",$last); }
if ($firsthyphen==true) { $first=ereg_replace(" ","-",$first); }

return htmlentities("$first $middle$last");

}

?>

Thing is, I'm getting bizarre behaviour where some characters become modified in a way I don't like - in particular, when the letter L follows an E with a diaresis (RaphaŽl, for example) it becomes upper case. Suggestions, anyone?

And if anyone wants to make that code shorter and more readable, I'd appreciate it greatly. :-)

James.
xx

--- End Message ---
--- Begin Message ---
Hi James
There is a bug in PHP for the capitalisation problem
http://bugs.php.net/bug.php?id=14655
If you check the link then a workaround was posted by someone.
HTH
Rich
-----Original Message-----
From: James Coates [mailto:[EMAIL PROTECTED]]
Sent: 28 November 2002 13:11
To: [EMAIL PROTECTED]
Subject: [PHP] Bizarreness with htmlentities() and other things


Hello!

I'm currently doing some work that requires a mySQL database of actor
names. For all my actors, I have three columns; first_name, last_name and
between_name. Because between_name can be written in many ways ("Peter van
Wibble" or "Fred d'Angelo), and the French have a habit of writing their
surnames in capitals, I wrote a little function to prepare the actor names
for output:

<?
  function actor_name($last,$middle,$first) {
  // because we have so many different name combinations, write out a string
  // that does capitalisation and the like properly (hopefully)
  // ex: actor_name("ANGELO","d'","Jean-Pierre") = Jean-Pierre d'Angelo

   // strtolower() everything because ucwords() doesn't work on mixed case
   $last=strtolower($last);
   $middle=strtolower($middle);
   $first=strtolower($first);

   // split hyphenated names so we can ucwords() them
   if (strpos($last,"-")) {
    $lasthyphen=true;
    $last=ereg_replace("-"," ",$last);
   } else { $lasthyphen=false; }

   if (strpos($first,"-")) {
    $firsthyphen=true;
    $first=ereg_replace("-"," ",$first);
   } else { $firsthyphen=false; }

   // if the "middle" name doesn't end with an apostrophe, add a space and
   // lowercase it just in case someone's mis-typed it
   if (!strrpos($middle,"'")) {
    $middle.=" ";
   }

   $last=ucwords($last);
   $first=ucwords($first);

   if ($lasthyphen==true) { $last=ereg_replace(" ","-",$last); }
   if ($firsthyphen==true) { $first=ereg_replace(" ","-",$first); }

  return htmlentities("$first $middle$last");

  }

?>

Thing is, I'm getting bizarre behaviour where some characters become
modified in a way I don't like - in particular, when the letter L follows
an E with a diaresis (RaphaŽl, for example) it becomes upper case.
Suggestions, anyone?

And if anyone wants to make that code shorter and more readable, I'd
appreciate it greatly. :-)

James.
xx


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



--- End Message ---
--- Begin Message ---
At 14:07 28/11/2002 +0000, Rich Gray wrote:

There is a bug in PHP for the capitalisation problem
Sounds like an internal Microsoft memo.  :-)

http://bugs.php.net/bug.php?id=14655
If you check the link then a workaround was posted by someone.
Cool. If I've got that right, it'll be fine on the production (Linux) server, so I have no need to worry. :-)

Many thanks,
James.

--- End Message ---
--- Begin Message --- Check your session files (usually in /tmp) if they are what they are supposed to be

Jason Romero wrote:

--when using session registered variables
--i can only get them to save as session variables for one page
--then on the next page they are gone
--far as i can tell the variables are not getting written over or unset
--and the session is not gettting destroyed
--any other ideas what it might be?

i tried the seggestions you guys had
and i came up with one more question
does the session cookie.cookie_lifetime have anything to do with the amount
of time that session variables can be stored
the session.use_cookies is on and register.globals is turned on
however session.cookie_lifetime is set to 0
so would this affect the session variable lifetime?






--- End Message ---
--- Begin Message ---
On Wed, 20 Nov 2002, Oliver Witt wrote:

> I'm looking for a script that enables users of password demanding web
> sites to change their password, in other words a script, that can write
> into the .htpsswrd file.

        Answering to an old mail in here but noticed you didn't get
        any replies yet. You should check File_HtAccess and File_Passwd
        packages at PEAR:

                http://pear.php.net/package-info.php?pacid=131
                http://pear.php.net/package-info.php?pacid=128

-- 
Mika Tuupola                      http://www.appelsiini.net/~tuupola/

--- End Message ---
--- Begin Message ---
At 15:46 28/11/2002 +0200, Mika Tuupola wrote:

> into the .htpsswrd file.

        Answering to an old mail in here but noticed you didn't get
        any replies yet. You should check File_HtAccess and File_Passwd
        packages at PEAR:

I quite like class.htpasswd - http://www.hotscripts.com/Detailed/3978.html

James.


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

Please can someone tell me how i can tell if a string contains a full stop?

thanks


--- End Message ---
--- Begin Message ---
You can use strstr:

if (strstr ($str, '.'))
        echo 'Full stop';
else
        echo 'No full stop';

Marco

-- 
------------
php|architect - The magazine for PHP Professionals
The first monthly worldwide magazine dedicated to PHP programmers

On Thu, 2002-11-28 at 08:49, Shaun wrote:
> Hi,
> 
> Please can someone tell me how i can tell if a string contains a full stop?
> 
> thanks
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


--- End Message ---
--- Begin Message ---
Archive php-4.3.0RC2.tar.gz contain directory autom4te-2.53.cache.
With this directory I can't build my own extension, because buildconf can't
find their.

Vadim Tkachenko.


"Andrei Zmievski" <[EMAIL PROTECTED]> ???????/???????? ? ????????
?????????: [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> The second release candidate of the inimitably fabulous PHP version 4.3.0
is
> out. It can be downloaded from http://qa.php.net. Give it a good testing!
>
> -Andrei
>


--- End Message ---
--- Begin Message ---
Hi Ernest E Vogelsinger,

On Sat, 23 Nov 2002 17:07:50 +0100, you wrote about "Re: [PHP] echo'ing
array contents through reference variable ... why doesn't this work???"
something that looked like this:

>At 16:50 23.11.2002, -<[ Rene Brehmer ]>- said:
>--------------------[snip]--------------------
>>Shouldn't 
>>      echo($$pdag[$n]);
>>be able to pull the string contents of the array? Or is there some extra
>>needed when using referenced variable?
>--------------------[snip]-------------------- 
>
>This is ambiguous: is it "$$pdag" indexed by "[$n]", or is it "$pdag[$n]"
>dereferenced? If you're using an interim variable you'll get what you need
>- either use (depends on your data layout which I don't know)
>    $temp = $pdag[$n];
>    echo $$temp;
>or
>    $temp = $$pdag;
>    echo $temp[$n];

Not sure about the correct terms in English, sorry ...

But to answer your question:
$pdag = "d".str_replace("-","",$premieredag[$i]);

where $premieredag is a date in form "2002-11-28".

So $n is then an index in the array that $pdag refers to.

But either way, writing echo(${$pdag}[$n]); got me the array contents as
desired ... so thank you. Now I can finally finish this thing ...

Thx

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

Thanks ... it totally did the trick ... if only I've had the time to
actually look at this before now ;-) ... 

thx

Rene

On Sat, 23 Nov 2002 19:20:02 +0100, you wrote about "Re: [PHP] echo'ing
array contents through reference variable" something that looked like
this:

>echo ${$pdag[$n]}; // is also possible in case the [$n] is the index to 
>pdag. Otherwise use this:
>echo ${$pdag}[$n];

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

Hello, 

I'm displaying the content of a mysql table with autoincrement index. I want to be 
able to select the each row from the table using the check boxes. In order to do that, 
i want to assign to each checkbox the name=index of selected row. 
I assign to the checkboxes the value of selected id, but I can't retreiveit later for 
further processing. My code looks like this

 $query = "SELECT * FROM reclamatie";
    $result = mysql_query($query) or die("Query failed");

    /* Printing results in HTML */
 
 echo "<table border=1>"; 
    echo "<tr><td></td><td>ID</td><td>Subject</td><td>Open</td><td>Close</td></tr>"; 

     while($row = MySQL_fetch_array($result)) { 
         echo  "<tr><td><form><input type=\"checkbox\" method=\"post\" 
name=\"{$row['id']}\"></form></td>"; // ??????????
            echo "<td><a href=\"lowerframe.php?id={$row['id']}\" 
target=\"lowerframe\">{$row['id']}</a></td>"; //for other purposes, it works fine
            echo "<td>{$row['subject']}</td>"; 
            echo "<td>{$row['open']}</td>";
   echo "<td>{$row['close']}</td></tr>";    
        } 
        echo "</table>"; 

Any sugestions if i want to use forms, something like



<form method="post" action="selectare.php?id=$row['id']>
<input type="Submit"  value="Trimite" >
</form>



Thanks, Adrian
--- End Message ---
--- Begin Message ---
> I'm displaying the content of a mysql table with autoincrement index.
I
> want to be able to select the each row from the table using the check
> boxes. In order to do that, i want to assign to each checkbox the
> name=index of selected row.
> I assign to the checkboxes the value of selected id, but I can't
> retreiveit later for further processing. My code looks like this
> 
>  $query = "SELECT * FROM reclamatie";
>     $result = mysql_query($query) or die("Query failed");
> 
>     /* Printing results in HTML */
> 
>  echo "<table border=1>";
>     echo
>
"<tr><td></td><td>ID</td><td>Subject</td><td>Open</td><td>Close</td></tr
>"
> ;
> 
>      while($row = MySQL_fetch_array($result)) {
>          echo  "<tr><td><form><input type=\"checkbox\" method=\"post\"
> name=\"{$row['id']}\"></form></td>"; // ??????????

It looks like your naming it as a number, which won't work for PHP. You
want to name all of your checkboxes the same, with a [] on the name to
make the results an array in PHP.

... name="id[]" value="{$row['id']}"

Then, you'll have $_POST['id'][x] as an array in PHP. Only the
checkboxes that were selected will be in the array, from zero to however
many were checked. The value of $_POST['id'][x] will be whatever was in
the value="..." part of the HTML checkbox...

---John Holmes...


--- End Message ---
--- Begin Message ---
If you have access to a database on your server then you can do the
following:
- user logs in to site (user enters unique username and password)
- once in they will be displayed with the 3-6 Questions
- after they answer the questions they hit submit which sends it to a PHP
script
- the PHP script will check a table in the database for the username and
increment a counter
- then if the counter is less than 10 then validate questions for right
answer, .....then you understand the rest


"Vicky" <[EMAIL PROTECTED]> wrote in message
006401c296d0$e287a6a0$0200a8c0@omnibook">news:006401c296d0$e287a6a0$0200a8c0@omnibook...
> A 'guessing'/knowledge game ^_^
>
> Basically I put a picture of a dog or cat up and they try to guess the
> breeds. If they get it right then they go to a page where they can
download
> their prize!
>
> Vicky
>


--- End Message ---
--- Begin Message --- hi,
which is faster; filling two array elements with two values, or making a two dimensional array to handle the two values in one element ...

which is better for Memory usage as well ?

(considering that both of them serve well in my situation)

thanx in advance

Regards,
Khalid Al-Kary




_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail

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

The user's choice is made from a drop down list of available items,
prior to running the routine itself.  The choices are predetermined
and kept in a personal table to be called by the routine.  This part
is finished to the point of putting the needed column names at the top
of the input columns on the form.  The choices are fixed spellings to
match formula if-then's, etc.   The use is for data manipulation and
so proper tracking of name/data is important in that regard, but the
final output figures go to the same categories in all cases so those
tables are fixed.  

The personal list table is to be called on the action page for keeping
the arrays in their proper order and usage.  The original idea was
that the list would be used somehow for creating the required
$_request's etc. 

But as you say, the tricky part is the naming of the columns, as we do
with the 'basic' column arrays.  I don't know if this can be done.
Thought it might be possible with 'dot' adds of functions or some such
to command lines built on the fly but haven't been able to make it
happen.  

But putting together what you and others are saying is giving me good
thoughts. :-)   Although I am still not sure how to code all of this,
much less express it, I am getting the idea that all 'columns' would
have the same array name and that the position of the data within that
single array will be the determining factor as to where it is applied.

That is if we need 3 user columns and 4 rows we will end up with a
single array of 12 values...  The three columns' fields would be
arranged as 1-4-7-10, 2-5-8-11 and 3-6-9-12.  

That should work nicely.  The column name list determines the number
of fields per row and the rest is automatic.  Perhaps I was going off
the deep end before but this method seems much less involved.  Anyone
see a problem with doing it this way?  

Many thanks to all and I apologize for the verbosity.  

Floyd
  



On Thu, 28 Nov 2002 01:28:48 -0800, you wrote:

>Floyd,
>I thought about this some and started noodling out a solution for you, but
>have a few questions before I go any farther on this.
>1. The part about users inputting their own column headers is relatively
>straight forward.  Something like this should work:
>
><?php
>if (!isset($start_button))
>    {
>    print "<form action=$PHP_SELF method=get>";
>    print "Input the following information";

> // these are your fixed cells
>    print "Name: <input type=text name=name size=20><br>";
>    print "Temp: <input type=text name=temp size=20><br>";
>    print "Time: <input type=text name=time size=20><br>";
>    print "Offset: <input type=text name=offset size=20><br>";

> // User inputs the number of additional cells needed
>  print "Input number of additional cells needed: <input type=text
>         name=additional_cells size=20><br>";
>  print "<input type=hidden name=start_button value=1>";
>  print "<input type=submit value=\" Hit it! \">";
>  print "</form>";
>  }


>if ($start_button=="1")
> {
> print "<form action=$PHP_SELF method=get>";
> print "Input the following information";
> // these are your fixed cells and they now contain user input
>   print "Name: <input type=text name=name value=\"$name\" size=20><br>";
>   print "Temp: <input type=text name=temp value=\"$temp\" size=20><br>";
>   print "Time: <input type=text name=time value=\"$time\" size=20><br>";
>   print "Offset: <input type=text name=offset value=\$offset\"
>size=20><br>";
> print "Input the names of the desired additional cells in the spaces
>provided.";
> // this is where your user will name the cells he asked to create
> for($i=1;$i<=$additional_cells;$i++)
>  {
>  print "$i <input type=text name=user_added[$i] size=20><br>";
>  }
> print "<input type=hidden name=additional_cells value=\"$additional_cells\"
>>";
> print "<input type=hidden name=start_button value=2>";
> print "<input type=submit value=\" Hit it! \">";
> print "</form>";
> }
>if ($start_button=="2")
>   {
>    print $name."<br>".$temp."<br>".$time."<br>".$offset."<br>";
>    for($i=1;$i<=$additional_cells;$i++)
>    {
>    print "user cell ".$i." ".$user_added[$i]."<br>";
>    }
>}
>?>
>
>
>2. Now comes the tricky part, and the part I'm unsure about.  You can
>convert the user input in the above so that it becomes the names of the
>input cells, or you can leave them in a numeric array.  Leaving them in a
>numeric array will be easier to deal with later.
>Also, other than the display of a table, what do you want the user input
>for?  If you're planning on doing any data manipulation, then your coding
>will get a bit hairy because you won't know what relation the user input
>data has to your standard data (name, time, temp and offset).  Finally, if
>you're planning on storing the data in a database table, each table will
>need to be created on the fly--it can be done, but if you're struggling with
>this, it'll take you some time to get the back end working.
>
>Hope this helps,
>Hugh
>
>----- Original Message -----
>From: "Floyd Baker" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Cc: "'Hugh Danaher'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
>Sent: Wednesday, November 27, 2002 5:24 PM
>Subject: Re: [PHP] dynamic arraynames
>
>
>>
>>
>> Well I might be in the wrong place.  I've also asked in the HTML list
>> now too but I'm still stuck and need some help.
>>
>> This is pretty much as clear as I can make it.  I'm up against a
>> mental block and even if it's as clear as glass to others I'm dead in
>> the water and would appreciate some pointers.  I have a bunch of
>> pieces but can't seem to string them together enough to make it work.
>>
>> Just trying to build an x-y array of data input fields and then send
>> them recursive to be used further down the program.
>>
>> I can do this fine with a fixed number of columns and rows of user
>> input but I cannot figure out how to make this happen using a variable
>> number of columns.  I'm a complete array amateur and would appreciate
>> a little assistance...
>>
>> I want it to look something like this:
>>
>> Name          Temp      Time      Offset    Etc.      As needed...
>> process 1    [input]   [input]   [input]   [input]   [inputs]
>> process 2    [input]   [input]   [input]   [input]   [inputs]
>> process 3    [input]   [input]   [input]   [input]   [inputs]
>> process 4    [input]   [input]   [input]   [input]   [inputs]
>>
>> Right now, for the three *basic* columns, I have the lines below in a
>> 'while' loop.
>>
>> <INPUT TYPE='text' NAME='temp[]' VALUE='$temp' SIZE='10'
>> MAXLENGTH='10'>
>> <INPUT TYPE='text' NAME='time[]' VALUE='$time' SIZE='10'
>> MAXLENGTH='10'>
>> <INPUT TYPE='text' NAME='offs[]' VALUE='$offs' SIZE='10'
>> MAXLENGTH='10'>
>>
>> But when it comes to adding additional columns that a user
>> determines are needed, I am lost.  Users might want to add 0, or 4, or
>> 10 additional items...  I would like only that number of usable
>> input columns be on the input-form, identified for what they contain,
>> and then be passed to the next page....
>>
>> Again, many thanks in advance.
>>
>> Floyd
>>
>>
>>
>>
>>
>>
>> On Sun, 24 Nov 2002 23:55:56 -0500, you wrote:
>>
>> >I'm sorry, but I'm still confused. Can you show us a sample of the data
>> >in the database and what you want the resulting form to look like for
>> >that data? Maybe that'll help.
>> >
>> >---John Holmes...
>>
>>
>>
>>
>>
>> --
>>

--

--- End Message ---
--- Begin Message ---
Well...

1 day = 60*60*24 = 86400

You figure it out from there :)

Just one example.

Aaron

-----Original Message-----
From: Dankshit [mailto:[EMAIL PROTECTED]] 
Sent: November 28, 2002 12:06 PM
To: PHP; PHP1
Subject: [PHP-DB] Help with date


How can i add days to a date??


------------------------------------------------------------------------
--------
        Equipe Pratic Sistemas
        Rodrigo CorrÍa
        Fone: (14) 441-1700
        [EMAIL PROTECTED]
        [EMAIL PROTECTED] 
     



--- End Message ---
--- Begin Message ---
(Thanks to all who've replied about the streaming
audio. Haven't had a chance to respond or anything
yet.)

Here is a problem I'm having similar to somethnig
someone just posted, but not quite the same. I'm not
toooooo experienced with the intricacies and
complications of arrays, but I have a bunch of fields
like this for a magazine organizer (best way to put
it, I guess):

$issuenumber[]
$issueheadline[]
$issuewriters[]
$issuemonth[]
$issueyear[]
$issuedescription[]
among other fields.

I would like to store this all in one multidimensional
array, like
$issue->number[]
$issue->headline[]
etc.

What is the syntax? I'm bumbling around right now.
Also, if I sort() the array by number, would the rest
of the fields be properly sorted? I assume so, but
don't want to find out the hard way that it doesn't.

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
--- End Message ---
--- Begin Message ---
Dear all ,
 Hello ! I am a student and going to write a suit of programme . The
producers as follow

 producer 1.
 User A add an new appointment A ( "open Winamp at 2:30 on computer B")
through IE in his local computer A .

 producer 2.
 Computer A send the message to server A through http . The Servlet /
ASP.net which locates on server A receives the message and send message to
computer B (IP or domain name of computer B is given , named
"www.computerB.com") .

 producer 3.
 Computer B receives the message from server A through http at 1:01 . It is
expected to implement the new added appointment A ( "open Winamp at 2:30 on
computer B" ) at given time .

 I know what to implement the producer 1 and 2. However , I don't know how
to implement producer 3. Do you mind to tell me how to make a PHP programme
to execute a centian routine at a given time ? Thank you !


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

> Do you mind to tell me how to make a PHP programme
> to execute a centian routine at a given time ? Thank you !

PHP doesn't have anything built in that'll do this for you (at least,
nothing that I'm aware of). 

The best solution is to call your script from your OS's scheduler - cron
under unix/linux, or task scheduler in Windows. I usually trigger the script
with lynx and pipe it to /dev/null, but if you have PHP compiled as a
standalone instead of a server module, you could call it directly.

Cheers
Jon
--- End Message ---
--- Begin Message ---
Hello

Is it possible to detect with PHP whether an email sent using the PHP
'mail' function has bounced back or has not been delivered?

I currently all ready check the email address using the 'ereg' function
before the mail function is called, but this only checks the format is
valid beforehand.

Ade

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

> Is it possible to detect with PHP whether an email sent using the PHP
> 'mail' function has bounced back or has not been delivered?
>
> I currently all ready check the email address using the 'ereg' function
> before the mail function is called, but this only checks the format is
> valid beforehand.


Yes, and No!

If you use the ReturnPath header SOME/most email servers will bounce msgs
that they can't deliver to an actual mailbox back to you (others drop such
msgs onto an Admin somewhere, lose them in the ether (the msgs not the
Admins...) etc, etc). Accordingly, use a distinct address for this/email
filing rules.

Opt-in email schemes which send a welcome/confirm email to new customers do
so for this reason - the only way to verify an email address is to use it
(and get some feedback from the addressee).

Of course, once you have 'located' a new user, you still have to cope with
those who close email accounts without advising you...

It's a wonderful world!
=dn



--- End Message ---
--- Begin Message --- Added to this: you won't receive the immediately, so you are not able to tell the user that sending
the mail has failed.

DL Neil wrote:

Hello Ade,


Is it possible to detect with PHP whether an email sent using the PHP
'mail' function has bounced back or has not been delivered?

I currently all ready check the email address using the 'ereg' function
before the mail function is called, but this only checks the format is
valid beforehand.


Yes, and No!

If you use the ReturnPath header SOME/most email servers will bounce msgs
that they can't deliver to an actual mailbox back to you (others drop such
msgs onto an Admin somewhere, lose them in the ether (the msgs not the
Admins...) etc, etc). Accordingly, use a distinct address for this/email
filing rules.

Opt-in email schemes which send a welcome/confirm email to new customers do
so for this reason - the only way to verify an email address is to use it
(and get some feedback from the addressee).

Of course, once you have 'located' a new user, you still have to cope with
those who close email accounts without advising you...

It's a wonderful world!
=dn






--- End Message ---
--- Begin Message ---
On Thu, 28 Nov 2002 17:54:46 -0000, you wrote:

>Hello
>
>Is it possible to detect with PHP whether an email sent using the PHP
>'mail' function has bounced back or has not been delivered?

Hi,

If you're using PHP on a unix/linux with sendmail you can set the
envelope sender via the 5th parameter to the mail function,
additional_parameters.  Normally the envelope sender is the username
that your web server process runs under (usually "nobody" if you're
using Apache), but you can set it to either your email address or an
email address you have setup specifically to catch bounces.  Example:

mail('[EMAIL PROTECTED]', 'Test email', 'This is a test', '',
'[EMAIL PROTECTED]');

Most MTA in existence will route DSNs to the envelope sender, not the
From: header.

Note that sendmail will add an X-Warning header if the user your web
server runs as isn't considered a sendmail "trusted user".  The
quickest way to fix this (on Redhat machines anyway) is to put the
username in /etc/mail/trusted-users.  Other systems and sendmail
installations may differ, so YMMV.

HTH...
--- End Message ---
--- Begin Message ---
What would php run as on a cobalt raq4 so I don't get the x header
warning
Best regards

-----Original Message-----
From: Michael Sims [mailto:[EMAIL PROTECTED]] 
Sent: 28 November 2002 19:51
To: [EMAIL PROTECTED]
Cc: Ade Smith
Subject: Re: [PHP] Detecting email bounces sent by the mail function?


On Thu, 28 Nov 2002 17:54:46 -0000, you wrote:

>Hello
>
>Is it possible to detect with PHP whether an email sent using the PHP 
>'mail' function has bounced back or has not been delivered?

Hi,

If you're using PHP on a unix/linux with sendmail you can set the
envelope sender via the 5th parameter to the mail function,
additional_parameters.  Normally the envelope sender is the username
that your web server process runs under (usually "nobody" if you're
using Apache), but you can set it to either your email address or an
email address you have setup specifically to catch bounces.  Example:

mail('[EMAIL PROTECTED]', 'Test email', 'This is a test', '',
'[EMAIL PROTECTED]');

Most MTA in existence will route DSNs to the envelope sender, not the
From: header.

Note that sendmail will add an X-Warning header if the user your web
server runs as isn't considered a sendmail "trusted user".  The quickest
way to fix this (on Redhat machines anyway) is to put the username in
/etc/mail/trusted-users.  Other systems and sendmail installations may
differ, so YMMV.

HTH...

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

--- End Message ---
--- Begin Message ---
Wow. This goes way beyond simply printing
multidimensional arrays. Here's some sample data:

$issue[]["number"] = "number";
$issue[]["headline"] = "headling";
$issue[]["writers"] = "writers";
$issue[]["list"] = "list";
$issue[]["senttosubscribers"] = "0";
$issue[]["month"] = "05";
$issue[]["year"] = "2003";
$issue[]["description"] = "description";

What I need to do now is count(), sort() by number,
and loop through this array.

I read that PHP is screwy when counting and sorting
multidimensional arrays, but they *have* to have come
up with a method, right?

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
--- End Message ---
--- Begin Message ---
if [$number] is unique, use it as the key:

// $issue[]["number"] = "number"; -- removed
$issue[$number]["headline"] = "headling";
$issue[$number]["writers"] = "writers";
$issue[$number]["list"] = "list";
$issue[$number]["senttosubscribers"] = "0";
$issue[$number]["month"] = "05";
$issue[$number]["year"] = "2003";
$issue[$number]["description"] = "description";

then sorting by the the number will be simple (ksort)

Mako Shark wrote:

Wow. This goes way beyond simply printing
multidimensional arrays. Here's some sample data:

$issue[]["number"] = "number";
$issue[]["headline"] = "headling";
$issue[]["writers"] = "writers";
$issue[]["list"] = "list";
$issue[]["senttosubscribers"] = "0";
$issue[]["month"] = "05";
$issue[]["year"] = "2003";
$issue[]["description"] = "description";

What I need to do now is count(), sort() by number,
and loop through this array.

I read that PHP is screwy when counting and sorting
multidimensional arrays, but they *have* to have come
up with a method, right?

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



--- End Message ---
--- Begin Message ---
Thanks to Paul and Marek for some ksort() advice. I'll
try that out as soon as I can count() these buggers.

A little more info on my count()ing.
I have $issue[0]["number"] to $issue[x]["number"] just
like any other multidimensional array (we'll call them
m-arrays for simplicity).

If I try to count($issue), I'll get all instances of
my array (instances?) mltipled by the number of
elements (don't know if this includes NULLs or not,
don't have NULLs). If I try to count($issue[]), it'll
give me the number of elements (8), which is also not
correct. If I try to count($issue[]["number"]) it says
I can't pass that to the count() function (which is
logical). But it leaves me with no way of count()ing
my instances.

My problem is I need to loop through these. So I can't
just assume that the count is count($issue[]) divided
by 8, because that won't work in a for loop. I suppose
I could just iterate through my for loop in jumps of
8, but that seems really hacky and unintuitive to
whomever has to figure out my code when I'm gone.

If there's a kcount(), I'm all for it. :)

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
--- End Message ---
--- Begin Message ---
<<if [$number] is unique, use it as the key:>>

Yeah, I'd thought of that except there's no guarantee
that it will be unique.

Plus, it makes it harder to go through with a simple
loop because $number really isn't guaranteed to be
numeric (okay, so I have to change the name). Plus, it
may not even start from 0, For instance, it doesn't
have to be from 1-10, it could be from 75-85.



__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
--- End Message ---
--- Begin Message ---
You don't need sequential numbers as your key.
Take this example:

/*** define some values ***/
$fruits['apple']['color']=$color;
$fruits['apple']['diameter']=$x;
$fruits['orange']['color']=$color;
$fruits['orange']['diameter']=$x;
$fruits['grape']['color']=$color;
$fruits['grape']['diameter']=$x;

/*** Grab the keys ***/
$fruit_types = array_keys($fruits);
$count = 0;
while ($count < count($fruit_types))
{
    $fruit = $fruit_types[$count];
    $color = $fruits[$fruit]['color'];
    $diameter = $fruits[$fruit]['diameter'];
}


Matt
----- Original Message ----- 
From: Mako Shark <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, November 28, 2002 3:45 PM
Subject: Re: [PHP] Multidimensional arrays (more and more...)


> <<if [$number] is unique, use it as the key:>>
> 
> Yeah, I'd thought of that except there's no guarantee
> that it will be unique.
> 
> Plus, it makes it harder to go through with a simple
> loop because $number really isn't guaranteed to be
> numeric (okay, so I have to change the name). Plus, it
> may not even start from 0, For instance, it doesn't
> have to be from 1-10, it could be from 75-85.
> 
> 
> 
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

--- End Message ---
--- Begin Message ---
Quick one, how do i read a file for a key word, say "TEXt", and the delete
the rest of the remaining file?




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

I would like to know has anybody being able to do this.

Each page has its own meta keywords and title.

I have searched lot of information about it but no luck.

any help or pointer with this would be greatly appreciated.

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

I am trying to make my free home page and my friend told me to download the php because it is for the web and i want to make a web page. so i downloaded the php with the flash plugin and i put it on my desktop and nothing showed up - i just want to make the free home page but the php does not work - i double click and noting happens

i have the windows 95 with internet exploerer with a pentium 100 drive

what do i do?

Ted

_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail

--- End Message ---
--- Begin Message ---
Welcome to the new world ;)

before clicking or asking start reading what is PHP (http://www.php.net),
and in what it could be usefull.
then you can getting started here :
http://www.php.net/manual/en/tutorial.php


----- Original Message -----
From: "Ted Frank" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, November 28, 2002 8:47 PM
Subject: [PHP] Help with the PHP


> Hello,
>
> I am trying to make my free home page and my friend told me to download
the
> php because it is for the web and i want to make a web page. so i
downloaded
> the php with the flash plugin and i put it on my desktop and nothing
showed
> up - i just want to make the free home page but the php does not work - i
> double click and noting happens
>
> i have the windows 95 with internet exploerer with a pentium 100 drive
>
> what do i do?
>
> Ted
>
> _________________________________________________________________
> Add photos to your e-mail with MSN 8. Get 2 months FREE*.
> http://join.msn.com/?page=features/featuredemail
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
Works like a charm, thank you!

Benny

"Ernest E Vogelsinger" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> At 23:11 27.11.2002, Ernest E Vogelsinger said:
> --------------------[snip]--------------------
> >If I understand you correctly you want to isolate either quoted strings
> >(with or without whitespace), or tokens separated by whitespace, as array
> >elements?
> >
> >For this you would first have to isolate the first quoted sentence, then
> >tokenize the part before, and loop this as long you're not done.
> >
> >Should work something like that:
> >
> > [...]
> >Disclaimer: untested as usual. _Should_ behave like this:
> --------------------[snip]--------------------
>
> I _should_ have tested. This script actually works the way you expect it
to be:
>
> ------------<code>------------
> <xmp>
> <?php
>
> function tokenize_search($input) {
>     $re = '/\s*(.*?)\s*"\s*([^"]*?)\s*"\s*(.*)/s';
>     /* look for 3 groups:
>        a - prematch - anything up to the first quote
>        b - match - anything until the next quote
>        c - postmatch - rest of the string
>     */
>     $tokens = array();
>     while (preg_match($re, $input, $aresult)) {
>         // aresult contains: [0]-total [1]-a [2]-b [3]-c
>         // tokenize the prematch
>         if ($aresult[1]) $tokens = array_merge($tokens, explode(' ',
> $aresult[1]));
>         array_push($tokens, $aresult[2]);
>         $input = $aresult[3];
>     }
>     // $input has the rest of the line
>     if ($input) $tokens = array_merge($tokens, explode(' ', $input));
>     return $tokens;
> }
>
> $string = "\"search for this sentence\" -NotForThisWord
> ButDefinitelyForThisWord";
> $tokens = tokenize_search($string);
> print_r($tokens);
>
> ?>
> ------------</code>------------
>
> The output of this script is:
>
> Array (
>     [0] => search for this sentence
>     [1] => -NotForThisWord
>     [2] => ButDefinitelyForThisWord
> )
>
>
> --
>    >O     Ernest E. Vogelsinger
>    (\)    ICQ #13394035
>     ^     http://www.vogelsinger.at/
>
>


--- End Message ---
--- Begin Message ---
hi
i have the following script:
--------------------------------
<?php
 session_name("MySession");
 session_start();
 echo "<h1>Session START</h1>";
 $HTTP_SESSION_VARS["mctini"] = parse_ini_file("mct.ini", true);;
 print_r($HTTP_SESSION_VARS["mctini"]);
?>
--------------------------------
everytime i reload the page, a new session will be generated! i do not want
that! when i take out the session_name() and reload the page a few times, NO
new session will be generated an the old one will be detecded everytime like
i would like to have it! what does this function session_name() indicated
that everytime a new session is generated...? how do i use this function
correctly?

thanx for all answers
regards, jŁrg zgraggen




--- End Message ---
--- Begin Message ---
<? include ('./header.php');
$query="select prodid, title FROM fatbeats_prod";
$result= mysql_query($query);
$names= mysql_fetch_assoc($result);

$query1="select prodid, price from fatbeats_prod";
$result1=mysql_query($query1);
$prices= mysql_fetch_assoc($result1);

 while (list($key,$val) = each($qty)) {
 $shoppingCart[$key] = $val;
}
while (list($key,$val) = each($shoppingCart)) {
 $currentName = $names[$key];
 $currentPrice = $prices[$key];
 echo "You added $val of $currentName to your cart, which costs
$currentPrice euro. <BR>";
}
 include ('./footer.php');
 ?>

What i need is to declare the arrays $names and $prices
And select the prodid as key and the title as val how can I do this?

I tried "select prodid as key, title as val
but that doesnt work.

thx for any help


--- End Message ---

Reply via email to