php-general Digest 11 Aug 2011 19:22:28 -0000 Issue 7440

Topics (messages 314487 through 314504):

Re: Problem with inserting numbers...
        314487 by: Tim Streater
        314488 by: Dajka Tamás
        314489 by: Jason Pruim
        314490 by: Tamara Temple
        314491 by: Florian Lemaitre
        314493 by: Ashley Sheridan
        314494 by: Andrew Ballard
        314495 by: Jim Lucas
        314496 by: Jason Pruim
        314497 by: Jason Pruim
        314504 by: Jim Lucas

Re: concatenating
        314492 by: Andre Polykanine

PHP 5.3.7RC5 Released for Testing
        314498 by: Ilia Alshanetsky

Re: Mapping HTTP URLs to a www/ subdirectory
        314499 by: Christian Weiske

form handling
        314500 by: Chris Stinemetz
        314501 by: Stuart Dallas
        314502 by: Ken Robinson

Re: i, em, strong and b in html5h
        314503 by: Grega Leskovšek

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
On 11 Aug 2011 at 02:22, Jason Pruim <[email protected]> wrote: 

> while ($num != "10000") {
>    while($row = mysql_fetch_assoc($result)) {
>        $padnum = number_pad($num, "4");
>        echo $row['areacode'] . "-" . $row['prefix'] . "-" . $padnum . "<BR>";
>        $num++;
>    }
>
>
> }

This is certain to fail. You've got the $num++ in the *inner* loop, and are 
checking its value in the *outer* loop. Think about it: suppose you enter the 
inner loop with $num being 9998. Suppose also that you then go round the inner 
loop 5 times. What is the value of $num when you then exit the inner loop in 
order to do the test against 10000 in the outer loop?

You need to rework that logic.

--
Cheers  --  Tim

--- End Message ---
--- Begin Message ---
While no tusing just one while loop?

$num = 0;
while ( ( $row = mysql_fetch_assoc($result) ) && $num++ <= 1000 ) {
        //do whatever you want and you'll get all results or max. 1000 lines ( 
whatever comes first )
}

Cheers,

        Tom

-----Original Message-----
From: Tim Streater [mailto:[email protected]] 
Sent: Thursday, August 11, 2011 11:22 AM
To: Jason Pruim
Cc: PHP General List
Subject: Re: [PHP] Problem with inserting numbers...

On 11 Aug 2011 at 02:22, Jason Pruim <[email protected]> wrote: 

> while ($num != "10000") {
>    while($row = mysql_fetch_assoc($result)) {
>        $padnum = number_pad($num, "4");
>        echo $row['areacode'] . "-" . $row['prefix'] . "-" . $padnum . "<BR>";
>        $num++;
>    }
>
>
> }

This is certain to fail. You've got the $num++ in the *inner* loop, and are 
checking its value in the *outer* loop. Think about it: suppose you enter the 
inner loop with $num being 9998. Suppose also that you then go round the inner 
loop 5 times. What is the value of $num when you then exit the inner loop in 
order to do the test against 10000 in the outer loop?

You need to rework that logic.

--
Cheers  --  Tim



--- End Message ---
--- Begin Message ---
Replies below


Jason Pruim
[email protected]



On Aug 10, 2011, at 11:08 PM, Ken Robinson wrote:

> At 09:22 PM 8/10/2011, Jason Pruim wrote:
>> So here I am attempting to generate some numbers to be inserted into a 
>> database... eventually they will make up a phone number (Which I've emailed 
>> about before and know about the bad ideas with it.. But it's the customer :))
>> 
>> Here is the code I am working with:
>> 
>> <?PHP
>> function number_pad($number,$n) {
>> return str_pad((int) $number,$n,"0",STR_PAD_LEFT);
>> }
>> 
>> $SQL = "SELECT * FROM Test WHERE `areacode` = '907' AND `prefix` = '200' 
>> LIMIT 5";
>> 
>> $result = mysql_query($SQL);
>> 
>> while ($num != "10000") {
>>    while($row = mysql_fetch_assoc($result)) {
>>        $padnum = number_pad($num, "4");
>>        echo $row['areacode'] . "-" . $row['prefix'] . "-" . $padnum . "<BR>";
>>        $num++;
>>    }
>> 
>> 
>> }
>> 
>> ?>
> 
> Try to avoid putting a database query in a loop.

But that's exactly what I need to do...  onceI have the code working with the 
echo I need to update the database with the numbers being displayed...

$fullnumber = $row['areacode'].$row['prefix'].$padnum;

$SQL = INSERT INTO Test ('fullnumber'( VALUES($fullnumber);


So I want that to be in a loop since it will be inserting roughly 10,000 
records for every areacode/prefix combination :)


> In the query only ask for the fields you are going to use, it's faster. Why 
> use your own function to pad a string, when there is a built-in function?

Because when I was doing my searching I came across the function I'm using 
before I saw the range function :)

> 
> Try this code (untested):
> <?php
> $nums = range(0,9999);
> $q = "SELECT areacode, prefix FROM Test WHERE `areacode` = '907' AND `prefix` 
> = '200' LIMIT 5";
> $rs = mysql_query($q);
> while ($row = mysql_fetch_assoc($rs)) {
>        foreach ($nums as $n) {
>                echo 
> sprintf('%03d-%03d-%04d',$row['areacode'],$row['prefix'],$n) "<br>\n";
>        }
> }
> ?>
> 

I will try this later today after the day job gets done...

Thanks for the help!



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

On Aug 10, 2011, at 8:22 PM, Jason Pruim wrote:

So here I am attempting to generate some numbers to be inserted into a database... eventually they will make up a phone number (Which I've emailed about before and know about the bad ideas with it.. But it's the customer :))

Here is the code I am working with:

<?PHP
function number_pad($number,$n) {
return str_pad((int) $number,$n,"0",STR_PAD_LEFT);
}

$SQL = "SELECT * FROM Test WHERE `areacode` = '907' AND `prefix` = '200' LIMIT 5";

$result = mysql_query($SQL);
//$num = "0000";
//foreach ($result as $key => $value) {
//    echo $key . "-" . $value . "-" . number_pad($num, "4") . "<BR>";
//    $num++;
//}

while ($num != "10000") {

Problem is here ^ You are testing a numeric $num with a string "10000", which $num will *never* equal. Leave off the quotes on the number.

   while($row = mysql_fetch_assoc($result)) {
       $padnum = number_pad($num, "4");
echo $row['areacode'] . "-" . $row['prefix'] . "-" . $padnum . "<BR>";
       $num++;
   }


}

?>

basically all I'm trying to do is generate the last 4 digits starting at 0000 and going up to 9999. for testing purposes I'm just echoing back but will eventually insert the complete number back into the database as a 7 digit string.

The error I'm getting is:

Fatal error: Maximum execution time of 30 seconds exceeded in /home/ pruimpho/public_html/jason/dev/clients/flewid/Phone/config/ phoneareacodes.php on line25

which is where the second while starts...

Does anyone know a better way to do this?

I'm off to finish searching google while waiting for some good news :)

Thanks Everyone!


Jason Pruim
[email protected]




--- End Message ---
--- Begin Message ---
Le 11/08/2011 13:08, Tamara Temple a écrit :

On Aug 10, 2011, at 8:22 PM, Jason Pruim wrote:
while ($num != "10000") {

Problem is here ^ You are testing a numeric $num with a string "10000", which $num will *never* equal. Leave off the quotes on the number.

Hum, I suggest you read this page properly :
http://www.php.net/manual/en/types.comparisons.php

exemple :

<?php
$num = 1;
$num++;
print ($num != 2 ? "different" : "equal") . PHP_EOL . ($num != "2" ? "different" : "equal") . PHP_EOL; print ($num !== 2 ? "different" : "equal") . PHP_EOL . ($num !== "2" ? "different" : "equal") . PHP_EOL;

result :

equal
equal
equal
different


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

Jason Pruim <[email protected]> wrote:

>Replies below
>
>
>Jason Pruim
>[email protected]
>
>
>
>On Aug 10, 2011, at 11:08 PM, Ken Robinson wrote:
>
>> At 09:22 PM 8/10/2011, Jason Pruim wrote:
>>> So here I am attempting to generate some numbers to be inserted into
>a database... eventually they will make up a phone number (Which I've
>emailed about before and know about the bad ideas with it.. But it's
>the customer :))
>>>
>>> Here is the code I am working with:
>>>
>>> <?PHP
>>> function number_pad($number,$n) {
>>> return str_pad((int) $number,$n,"0",STR_PAD_LEFT);
>>> }
>>>
>>> $SQL = "SELECT * FROM Test WHERE `areacode` = '907' AND `prefix` =
>'200' LIMIT 5";
>>>
>>> $result = mysql_query($SQL);
>>>
>>> while ($num != "10000") {
>>>    while($row = mysql_fetch_assoc($result)) {
>>>        $padnum = number_pad($num, "4");
>>>        echo $row['areacode'] . "-" . $row['prefix'] . "-" . $padnum
>. "<BR>";
>>>        $num++;
>>>    }
>>>
>>>
>>> }
>>>
>>> ?>
>>
>> Try to avoid putting a database query in a loop.
>
>But that's exactly what I need to do...  onceI have the code working
>with the echo I need to update the database with the numbers being
>displayed...
>
>$fullnumber = $row['areacode'].$row['prefix'].$padnum;
>
>$SQL = INSERT INTO Test ('fullnumber'( VALUES($fullnumber);
>
>
>So I want that to be in a loop since it will be inserting roughly
>10,000 records for every areacode/prefix combination :)
>
>
>> In the query only ask for the fields you are going to use, it's
>faster. Why use your own function to pad a string, when there is a
>built-in function?
>
>Because when I was doing my searching I came across the function I'm
>using before I saw the range function :)
>
>>
>> Try this code (untested):
>> <?php
>> $nums = range(0,9999);
>> $q = "SELECT areacode, prefix FROM Test WHERE `areacode` = '907' AND
>`prefix` = '200' LIMIT 5";
>> $rs = mysql_query($q);
>> while ($row = mysql_fetch_assoc($rs)) {
>>        foreach ($nums as $n) {
>>                echo
>sprintf('%03d-%03d-%04d',$row['areacode'],$row['prefix'],$n) "<br>\n";
>>        }
>> }
>> ?>
>>
>
>I will try this later today after the day job gets done...
>
>Thanks for the help!
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

You might need to insert 10,000 rows, but that doesn't mean you need to perform 
10,000 separate inserts. Use bulk inserts to ease the load. Also, try to run 
the script over the cli if you can, it will use less memory (no Apache and its 
posse) and it won't time out.

Thanks,
Ash
http://www.ashleysheridan.co.uk
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

--- End Message ---
--- Begin Message ---
On Wed, Aug 10, 2011 at 9:22 PM, Jason Pruim <[email protected]> wrote:
> So here I am attempting to generate some numbers to be inserted into a 
> database... eventually they will make up a phone number (Which I've emailed 
> about before and know about the bad ideas with it.. But it's the customer :))
>
> Here is the code I am working with:
>
> <?PHP
> function number_pad($number,$n) {
> return str_pad((int) $number,$n,"0",STR_PAD_LEFT);
> }
>
> $SQL = "SELECT * FROM Test WHERE `areacode` = '907' AND `prefix` = '200' 
> LIMIT 5";
>
> $result = mysql_query($SQL);
> //$num = "0000";
> //foreach ($result as $key => $value) {
> //    echo $key . "-" . $value . "-" . number_pad($num, "4") . "<BR>";
> //    $num++;
> //}
>
> while ($num != "10000") {
>    while($row = mysql_fetch_assoc($result)) {
>        $padnum = number_pad($num, "4");
>        echo $row['areacode'] . "-" . $row['prefix'] . "-" . $padnum . "<BR>";
>        $num++;
>    }
>
>
> }
>
> ?>
>
> basically all I'm trying to do is generate the last 4 digits starting at 0000 
> and going up to 9999. for testing purposes I'm just echoing back but will 
> eventually insert the complete number back into the database as a 7 digit 
> string.
>
> The error I'm getting is:
>
> Fatal error: Maximum execution time of 30 seconds exceeded in 
> /home/pruimpho/public_html/jason/dev/clients/flewid/Phone/config/phoneareacodes.php
>  on line25
>
> which is where the second while starts...
>
> Does anyone know a better way to do this?
>
> I'm off to finish searching google while waiting for some good news :)
>
> Thanks Everyone!
>
>
> Jason Pruim
> [email protected]

You could always push it off to MySQL. I don't have a MySQL instance
available to test right now, but I ran this on SQL Server and it
should be generic enough to port without much change. Basically, you
just load a table with a single tinyint column with the digits between
0 and 9, and then allow the database to cross join that table 4 times
to get 10000 resulting rows numbered 0000 through 9999.
The cross join on this database server executes in around 44ms.


-- Create a temporary table containing the digits 0 through 9
CREATE TABLE Digits (
    n   tinyint NOT NULL PRIMARY KEY
        CHECK (n BETWEEN 0 AND 9)
)

INSERT INTO Digits
VALUES
(0),
(1),
(2),
(3),
(4),
(5),
(6),
(7),
(8),
(9)



-- Cross join the digits table 4 times to load into a table called numbers.

SELECT  CONVERT(char(1), Thousands.n) +
        CONVERT(char(1), Hundreds.n) +
        CONVERT(char(1), Tens.n) +
        CONVERT(char(1), Ones.n) AS Number
INTO    Numbers
FROM    Digits AS Thousands,
        Digits AS Hundreds,
        Digits AS Tens,
        Digits AS Ones
ORDER BY
    Thousands.n, Hundreds.n, Tens.n, Ones.n


SELECT  *
FROM    Numbers

-- Drop the temporary digits table
DROP TABLE Digits



Andrew

--- End Message ---
--- Begin Message ---
On 8/10/2011 6:22 PM, Jason Pruim wrote:
> So here I am attempting to generate some numbers to be inserted into a 
> database... eventually they will make up a phone number (Which I've emailed 
> about before and know about the bad ideas with it.. But it's the customer :)) 
> 
> Here is the code I am working with:
> 
> <?PHP
> function number_pad($number,$n) {
> return str_pad((int) $number,$n,"0",STR_PAD_LEFT);
> }
> 
> $SQL = "SELECT * FROM Test WHERE `areacode` = '907' AND `prefix` = '200' 
> LIMIT 5";
> 
> $result = mysql_query($SQL);
> //$num = "0000";
> //foreach ($result as $key => $value) {
> //    echo $key . "-" . $value . "-" . number_pad($num, "4") . "<BR>";
> //    $num++;
> //}
> 
> while ($num != "10000") {
>     while($row = mysql_fetch_assoc($result)) {
>         $padnum = number_pad($num, "4");
>         echo $row['areacode'] . "-" . $row['prefix'] . "-" . $padnum . "<BR>";
>         $num++;
>     }
>     
> 
> }
> 
> ?>
> 
> basically all I'm trying to do is generate the last 4 digits starting at 0000 
> and going up to 9999. for testing purposes I'm just echoing back but will 
> eventually insert the complete number back into the database as a 7 digit 
> string.
> 
> The error I'm getting is:
> 
> Fatal error: Maximum execution time of 30 seconds exceeded in 
> /home/pruimpho/public_html/jason/dev/clients/flewid/Phone/config/phoneareacodes.php
>  on line25
> 
> which is where the second while starts...
> 
> Does anyone know a better way to do this? 
> 
> I'm off to finish searching google while waiting for some good news :)
> 
> Thanks Everyone!
> 
> 
> Jason Pruim
> [email protected]
> 
> 
> 

Jason,

Here is my rendition of what you should do.

<?PHP

$SQL = "SELECT  areacode, prefix
        FROM    Test
        WHERE   `areacode` = '907'
        AND     `prefix` = '200'";

$result = mysql_query($SQL);

$values = '';

while( $row = mysql_fetch_assoc($result) ) {
  foreach ( range(0, 9999) AS $n ) {
    $values .= $row['areacode'] . '-' . $row['prefix'] . '-' .
               str_pad($n, 4, '0', STR_PAD_LEFT);
  }
}

echo $values;

?>

It will be much faster if you build the complete string in memory then echo out
the built string.

Jim Lucas

--- End Message ---
--- Begin Message ---
Jason Pruim
[email protected]


On Aug 11, 2011, at 9:35 AM, Andrew Ballard wrote:

> On Wed, Aug 10, 2011 at 9:22 PM, Jason Pruim <[email protected]> wrote:
>> So here I am attempting to generate some numbers to be inserted into a 
>> database... eventually they will make up a phone number (Which I've emailed 
>> about before and know about the bad ideas with it.. But it's the customer :))
>> 
>> Here is the code I am working with:
>> 
>> <?PHP
>> function number_pad($number,$n) {
>> return str_pad((int) $number,$n,"0",STR_PAD_LEFT);
>> }
>> 
>> $SQL = "SELECT * FROM Test WHERE `areacode` = '907' AND `prefix` = '200' 
>> LIMIT 5";
>> 
>> $result = mysql_query($SQL);
>> //$num = "0000";
>> //foreach ($result as $key => $value) {
>> //    echo $key . "-" . $value . "-" . number_pad($num, "4") . "<BR>";
>> //    $num++;
>> //}
>> 
>> while ($num != "10000") {
>>    while($row = mysql_fetch_assoc($result)) {
>>        $padnum = number_pad($num, "4");
>>        echo $row['areacode'] . "-" . $row['prefix'] . "-" . $padnum . "<BR>";
>>        $num++;
>>    }
>> 
>> 
>> }
>> 
>> ?>
>> 
>> basically all I'm trying to do is generate the last 4 digits starting at 
>> 0000 and going up to 9999. for testing purposes I'm just echoing back but 
>> will eventually insert the complete number back into the database as a 7 
>> digit string.
>> 
>> The error I'm getting is:
>> 
>> Fatal error: Maximum execution time of 30 seconds exceeded in 
>> /home/pruimpho/public_html/jason/dev/clients/flewid/Phone/config/phoneareacodes.php
>>  on line25
>> 
>> which is where the second while starts...
>> 
>> Does anyone know a better way to do this?
>> 
>> I'm off to finish searching google while waiting for some good news :)
>> 
>> Thanks Everyone!
>> 
>> 
>> Jason Pruim
>> [email protected]
> 
> You could always push it off to MySQL. I don't have a MySQL instance
> available to test right now, but I ran this on SQL Server and it
> should be generic enough to port without much change. Basically, you
> just load a table with a single tinyint column with the digits between
> 0 and 9, and then allow the database to cross join that table 4 times
> to get 10000 resulting rows numbered 0000 through 9999.
> The cross join on this database server executes in around 44ms.
> 
> 
> -- Create a temporary table containing the digits 0 through 9
> CREATE TABLE Digits (
>    n   tinyint NOT NULL PRIMARY KEY
>        CHECK (n BETWEEN 0 AND 9)
> )
> 
> INSERT INTO Digits
> VALUES
> (0),
> (1),
> (2),
> (3),
> (4),
> (5),
> (6),
> (7),
> (8),
> (9)
> 
> 
> 
> -- Cross join the digits table 4 times to load into a table called numbers.
> 
> SELECT  CONVERT(char(1), Thousands.n) +
>        CONVERT(char(1), Hundreds.n) +
>        CONVERT(char(1), Tens.n) +
>        CONVERT(char(1), Ones.n) AS Number
> INTO    Numbers
> FROM    Digits AS Thousands,
>        Digits AS Hundreds,
>        Digits AS Tens,
>        Digits AS Ones
> ORDER BY
>    Thousands.n, Hundreds.n, Tens.n, Ones.n
> 
> 
> SELECT  *
> FROM    Numbers
> 
> -- Drop the temporary digits table
> DROP TABLE Digits
> 
> 
> 
> Andrew

Hey Andrew,

Interesting idea... I'm so used to doing it all from PHP that I forget a 
database can be more then just a storage engine sometimes :)

I'll definitely give it a try tonight!

Thanks Andrew!

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


--- End Message ---
--- Begin Message ---
Jason Pruim
[email protected]


On Aug 11, 2011, at 11:52 AM, Jim Lucas wrote:

> On 8/10/2011 6:22 PM, Jason Pruim wrote:
>> So here I am attempting to generate some numbers to be inserted into a 
>> database... eventually they will make up a phone number (Which I've emailed 
>> about before and know about the bad ideas with it.. But it's the customer 
>> :)) 
>> 
>> Here is the code I am working with:
>> 
>> <?PHP
>> function number_pad($number,$n) {
>> return str_pad((int) $number,$n,"0",STR_PAD_LEFT);
>> }
>> 
>> $SQL = "SELECT * FROM Test WHERE `areacode` = '907' AND `prefix` = '200' 
>> LIMIT 5";
>> 
>> $result = mysql_query($SQL);
>> //$num = "0000";
>> //foreach ($result as $key => $value) {
>> //    echo $key . "-" . $value . "-" . number_pad($num, "4") . "<BR>";
>> //    $num++;
>> //}
>> 
>> while ($num != "10000") {
>>    while($row = mysql_fetch_assoc($result)) {
>>        $padnum = number_pad($num, "4");
>>        echo $row['areacode'] . "-" . $row['prefix'] . "-" . $padnum . "<BR>";
>>        $num++;
>>    }
>> 
>> 
>> }
>> 
>> ?>
>> 
>> basically all I'm trying to do is generate the last 4 digits starting at 
>> 0000 and going up to 9999. for testing purposes I'm just echoing back but 
>> will eventually insert the complete number back into the database as a 7 
>> digit string.
>> 
>> The error I'm getting is:
>> 
>> Fatal error: Maximum execution time of 30 seconds exceeded in 
>> /home/pruimpho/public_html/jason/dev/clients/flewid/Phone/config/phoneareacodes.php
>>  on line25
>> 
>> which is where the second while starts...
>> 
>> Does anyone know a better way to do this? 
>> 
>> I'm off to finish searching google while waiting for some good news :)
>> 
>> Thanks Everyone!
>> 
>> 
>> Jason Pruim
>> [email protected]
>> 
>> 
>> 
> 
> Jason,
> 
> Here is my rendition of what you should do.
> 
> <?PHP
> 
> $SQL = "SELECT  areacode, prefix
>        FROM    Test
>        WHERE   `areacode` = '907'
>        AND     `prefix` = '200'";
> 
> $result = mysql_query($SQL);
> 
> $values = '';
> 
> while( $row = mysql_fetch_assoc($result) ) {
>  foreach ( range(0, 9999) AS $n ) {
>    $values .= $row['areacode'] . '-' . $row['prefix'] . '-' .
>               str_pad($n, 4, '0', STR_PAD_LEFT);
>  }
> }
> 
> echo $values;
> 
> ?>
> 
> It will be much faster if you build the complete string in memory then echo 
> out
> the built string.

Hey Jim,

Would that still hold true with inserting into a database which is the true end 
of it? This is going to be a one time thing I'm doing and I'm trying to make it 
a learning experience as I go since that's what everything should be right?


> 
> Jim Lucas


--- End Message ---
--- Begin Message ---
On 8/11/2011 9:34 AM, Jason Pruim wrote:
> 
> Hey Jim,
> 
> Would that still hold true with inserting into a database which is the true 
> end of it? This is going to be a one time thing I'm doing and I'm trying to 
> make it a learning experience as I go since that's what everything should be 
> right?
> 

Yes, taking one of your other emails, you would do something like this.

<?PHP

$SQL = "SELECT  areacode, prefix
        FROM    Test
        WHERE   `areacode` = '907'
        AND     `prefix` = '200'";

$result = mysql_query($SQL);

$values = '';

while( $row = mysql_fetch_assoc($result) ) {
  foreach ( range(0, 9999) AS $n ) {
    $values .= " VALUES ('".
               sprintf('%03d-%03d-%04d', $row['areacode'], $row['prefix'], $n) .
               "')";
  }
}
echo 'INSERT INTO Test (fullnumber) ' . $values;

?>

You should see...

INSERT INTO Test (fullnumber) VALUES ('907-200-0000') VALUES ('907-200-0001')
VALUES ('907-200-0001') etc...

What this allows you to do is have one long string generated in memory then
inserted into the DB.  If you have any type of indexes on this table/column then
it would only require one re-indexing of the table for the single INSERT
statement vs 10000 re-indexes for 10000 separate INSERT statements.

Cuts the DB processing time down a lot.

Also, just so you know, if you place set_time_limit(0); at the top of the
script, it will allow the script to run as long as it needs to.

See: http://php.net/manual/en/function.set-time-limit.php

Jim Lucas

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

      

CS> Is it possible to concatenate a string and an element from a
CS> mysql_fetch_assoc array? I haven't had much luck searching google.

CS> Such as concatenating "results" with ' . $posts_row['store_tptest'] .
CS> ' so that if there are no elements returned nothing will be displayed?

if (!empty($posts_row['store_tptest'])) $str="results 
".$posts_rows['store_tptest'];
-- 
With best regards from Ukraine,
Andre
Skype: Francophile
My blog: http://oire.org/menelion (mostly in Russian)
Twitter: http://twitter.com/m_elensule
Facebook: http://facebook.com/menelion


--- End Message ---
--- Begin Message ---
The fifth and final release candidate of 5.3.7 was just released for
testing and can be downloaded here:

https://downloads.php.net/ilia/php-5.3.7RC5.tar.bz2 (md5sum:
2604b92812e213287fa0fbc5d61223db)
https://downloads.php.net/ilia/php-5.3.7RC5.tar.gz (md5sum:
2d3315be5ef7ab90ca359978f36c2001)

The Windows binaries are available at: http://windows.php.net/qa/

This RC is in place to validate the changes resulting from various
code adjustments made to address issues identified by static analysis.
If no issues arise the final release will be made next week.

To make sure we can finally get 5.3.7 out of the door, I would like to
ask that all developers refrain from making commits into the 5.3
branch, until the final release is made (especially those on working
on Coverity identified issues).

PHP 5.3.7 is focused on improving the stability and security. To
ensure that the release is solid, please test this RC against your
code base and report any problems that you encounter.

To find out what was changed since the last release please refer to
the NEWS file found within the archive or on
http://svn.php.net/viewvc/php/php-src/tags/php_5_3_7RC5/NEWS?revision=HEAD&view=markup

Windows users please mind that we don't provide VS6 builds anymore
since PHP 5.3.6.

Ilia Alshanetsky

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


I'm failing to create a .phar file for SemanticScuttle[1], a
self-hosted social bookmarking application.

The directory layout of SC is as follows:
- data/
- doc/
- scripts/
- src/
  - SemanticScuttle/
    - Service.php
- www/
  - index.php
  - edit.php

The separation of src/, data/ and www/ is to be sure only relevant
files are exposed to the web visitor, keeping files in data/, scripts/
and src/ only accessible via the file system, but not via the web
server.

I am trying to do the same with the .phar: Have all www/ files
accessible from outside while still having src/ and scripts/ in the
.phar for CLI access.

There seemed to be several possible solutions:

1. Modify $_SERVER['REQUEST_URI']
by adding /www/, so the normal phar web mapping code would take place.
This does not work - the phar C code uses the original SERVER
variables, not the ones from PHP:
> When executed by a web-based sapi, this reads
> $_SERVER['REQUEST_URI'] (the actual original value) 

2. Use webPhar()'s mapping functionality.
This is very hard to achieve, because I have over 200 files that need
to be accessible, and I don't want to add all that mappings.


Is there a better solution to map all web/HTTP requests to the phar to
a subdirectory inside the phar?


-- 
Regards/Mit freundlichen Grüßen
Christian Weiske

-=≡ Geeking around in the name of science since 1982 ≡=-

Attachment: signature.asc
Description: PGP signature


--- End Message ---
--- Begin Message ---
I have two forms on the same php script. Is it possible to submit both
forms to the same action="processform.php" with a single submit
button?

If so would you give me examples on how to handle this?

I will also continue searching google.

Thank you,

Chris

--- End Message ---
--- Begin Message ---
On 11 Aug 2011, at 19:25, Chris Stinemetz wrote:

> I have two forms on the same php script. Is it possible to submit both
> forms to the same action="processform.php" with a single submit
> button?
> 
> If so would you give me examples on how to handle this?

Three options spring to mind...

1) Combine them into one form in the HTML.

2) Run some JS on submit that combines the values into one form and submits 
that.

3) Use AJAX to submit the forms separately but simultaneously.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

--- End Message ---
--- Begin Message ---
At 02:25 PM 8/11/2011, Chris Stinemetz wrote:
I have two forms on the same php script. Is it possible to submit both
forms to the same action="processform.php" with a single submit
button?

If you want to submit at the same time, why do you have two forms?

Ken


--- End Message ---
--- Begin Message ---
There was a topic on that a while ago and I am now reading Introducing
HTML 5 from Bruce Lawson and Remy Sharp (pages 58-59) in mental
hospital. It is not
so bad as it seems, but I do not read email every day. They do not
have wireless :(

All four are valid in html5: em and strong marks up for
emphasis/importance that subtly changes the meaning of the sentence.
Examples: "Do you live in Paris?" <p>Np, my <em>name</em> is Paris. I
live in <em>Ljubljana</em>.</p><p><strong>Warning! This is a nudistic
beach</strong></p>

<i>:alternate voice or mood, taxonomic designation, technical term,
idiomatic phrase from another language, a thought, a ship name or
prose whose typographical presentation is italicized
<p>The <i>Titanic</i> sails.</p><p>The design needs a bit more <i
lang="fr">ooh la la</i></p><p><i>Gluteus maximus</i>

<b>:no extra importance, key words, document abstract, product names
in a review or just spans of text whose typicial typographic
presentation is boldened.
<p>I like <b>ice cream</b>, so for my birthday they gave me <b>an ice
cream maker machine</b>

It is no longer necessary to put attributes in quotes unless there is
space in the attribute word. But I still put them :).
<small> is now for smallprint copyright notice - the meaning of small
has changed</small>

<applet> is deprecated, use <embed> instead and <embed> is not
deprecated anymore.

And it is a very good book so far (two chapters).

♥♥♥ When the sun rises I receive and when it sets I forgive! ♥♥♥
˜♥ -> http://moj.skavt.net/gleskovs/ <- ♥ Always, Grega Leskovšek

--- End Message ---

Reply via email to