Re: [PHP] Problem with inserting numbers...

2011-08-11 Thread Tim Streater
On 11 Aug 2011 at 02:22, Jason Pruim  wrote: 

> while ($num != "1") {
>while($row = mysql_fetch_assoc($result)) {
>$padnum = number_pad($num, "4");
>echo $row['areacode'] . "-" . $row['prefix'] . "-" . $padnum . "";
>$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 1 in the outer loop?

You need to rework that logic.

--
Cheers  --  Tim

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

RE: [PHP] Problem with inserting numbers...

2011-08-11 Thread Dajka Tamás
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:t...@clothears.org.uk] 
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  wrote: 

> while ($num != "1") {
>while($row = mysql_fetch_assoc($result)) {
>$padnum = number_pad($num, "4");
>echo $row['areacode'] . "-" . $row['prefix'] . "-" . $padnum . "";
>$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 1 in the outer loop?

You need to rework that logic.

--
Cheers  --  Tim



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



Re: [PHP] Problem with inserting numbers...

2011-08-11 Thread Jason Pruim
Replies below


Jason Pruim
li...@pruimphotography.com



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:
>> 
>> > 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 != "1") {
>>while($row = mysql_fetch_assoc($result)) {
>>$padnum = number_pad($num, "4");
>>echo $row['areacode'] . "-" . $row['prefix'] . "-" . $padnum . "";
>>$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):
>  $nums = range(0,);
> $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) "\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



Re: [PHP] Problem with inserting numbers...

2011-08-11 Thread Tamara Temple


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:

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


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

while ($num != "1") {


Problem is here ^  You are testing a numeric $num with a string  
"1", 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 . "";

   $num++;
   }


}

?>

basically all I'm trying to do is generate the last 4 digits  
starting at  and going up to . 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
pru...@gmail.com





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



Re: [PHP] Problem with inserting numbers...

2011-08-11 Thread Florian Lemaitre

Le 11/08/2011 13:08, Tamara Temple a écrit :


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

while ($num != "1") {


Problem is here ^  You are testing a numeric $num with a string 
"1", 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 :

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


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



Re: [PHP] concatenating

2011-08-11 Thread Andre Polykanine

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


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



Re: [PHP] Problem with inserting numbers...

2011-08-11 Thread Ashley Sheridan


Jason Pruim  wrote:

>Replies below
>
>
>Jason Pruim
>li...@pruimphotography.com
>
>
>
>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:
>>>
>>> >> 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 != "1") {
>>>while($row = mysql_fetch_assoc($result)) {
>>>$padnum = number_pad($num, "4");
>>>echo $row['areacode'] . "-" . $row['prefix'] . "-" . $padnum
>. "";
>>>$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):
>> > $nums = range(0,);
>> $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) "\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.

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



Re: [PHP] Problem with inserting numbers...

2011-08-11 Thread Andrew Ballard
On Wed, Aug 10, 2011 at 9: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:
>
>  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 = "";
> //foreach ($result as $key => $value) {
> //    echo $key . "-" . $value . "-" . number_pad($num, "4") . "";
> //    $num++;
> //}
>
> while ($num != "1") {
>    while($row = mysql_fetch_assoc($result)) {
>        $padnum = number_pad($num, "4");
>        echo $row['areacode'] . "-" . $row['prefix'] . "-" . $padnum . "";
>        $num++;
>    }
>
>
> }
>
> ?>
>
> basically all I'm trying to do is generate the last 4 digits starting at  
> and going up to . 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
> pru...@gmail.com

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 1 resulting rows numbered  through .
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
INTONumbers
FROMDigits AS Thousands,
Digits AS Hundreds,
Digits AS Tens,
Digits AS Ones
ORDER BY
Thousands.n, Hundreds.n, Tens.n, Ones.n


SELECT  *
FROMNumbers

-- Drop the temporary digits table
DROP TABLE Digits



Andrew

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



Re: [PHP] Problem with inserting numbers...

2011-08-11 Thread Jim Lucas
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:
> 
>  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 = "";
> //foreach ($result as $key => $value) {
> //echo $key . "-" . $value . "-" . number_pad($num, "4") . "";
> //$num++;
> //}
> 
> while ($num != "1") {
> while($row = mysql_fetch_assoc($result)) {
> $padnum = number_pad($num, "4");
> echo $row['areacode'] . "-" . $row['prefix'] . "-" . $padnum . "";
> $num++;
> }
> 
> 
> }
> 
> ?>
> 
> basically all I'm trying to do is generate the last 4 digits starting at  
> and going up to . 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
> pru...@gmail.com
> 
> 
> 

Jason,

Here is my rendition of what you should do.



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

Jim Lucas

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



Re: [PHP] Problem with inserting numbers...

2011-08-11 Thread Jason Pruim

Jason Pruim
pru...@gmail.com


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

> On Wed, Aug 10, 2011 at 9: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:
>> 
>> > 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 = "";
>> //foreach ($result as $key => $value) {
>> //echo $key . "-" . $value . "-" . number_pad($num, "4") . "";
>> //$num++;
>> //}
>> 
>> while ($num != "1") {
>>while($row = mysql_fetch_assoc($result)) {
>>$padnum = number_pad($num, "4");
>>echo $row['areacode'] . "-" . $row['prefix'] . "-" . $padnum . "";
>>$num++;
>>}
>> 
>> 
>> }
>> 
>> ?>
>> 
>> basically all I'm trying to do is generate the last 4 digits starting at 
>>  and going up to . 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
>> pru...@gmail.com
> 
> 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 1 resulting rows numbered  through .
> 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
> INTONumbers
> FROMDigits AS Thousands,
>Digits AS Hundreds,
>Digits AS Tens,
>Digits AS Ones
> ORDER BY
>Thousands.n, Hundreds.n, Tens.n, Ones.n
> 
> 
> SELECT  *
> FROMNumbers
> 
> -- 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
> 


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



Re: [PHP] Problem with inserting numbers...

2011-08-11 Thread Jason Pruim

Jason Pruim
pru...@gmail.com


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:
>> 
>> > 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 = "";
>> //foreach ($result as $key => $value) {
>> //echo $key . "-" . $value . "-" . number_pad($num, "4") . "";
>> //$num++;
>> //}
>> 
>> while ($num != "1") {
>>while($row = mysql_fetch_assoc($result)) {
>>$padnum = number_pad($num, "4");
>>echo $row['areacode'] . "-" . $row['prefix'] . "-" . $padnum . "";
>>$num++;
>>}
>> 
>> 
>> }
>> 
>> ?>
>> 
>> basically all I'm trying to do is generate the last 4 digits starting at 
>>  and going up to . 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
>> pru...@gmail.com
>> 
>> 
>> 
> 
> Jason,
> 
> Here is my rendition of what you should do.
> 
>  
> $SQL = "SELECT  areacode, prefix
>FROMTest
>WHERE   `areacode` = '907'
>AND `prefix` = '200'";
> 
> $result = mysql_query($SQL);
> 
> $values = '';
> 
> while( $row = mysql_fetch_assoc($result) ) {
>  foreach ( range(0, ) 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


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



[PHP] PHP 5.3.7RC5 Released for Testing

2011-08-11 Thread Ilia Alshanetsky
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

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



[PHP] Phar: Mapping HTTP URLs to a www/ subdirectory

2011-08-11 Thread Christian Weiske
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 ≡=-


signature.asc
Description: PGP signature


[PHP] form handling

2011-08-11 Thread Chris Stinemetz
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

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



Re: [PHP] form handling

2011-08-11 Thread Stuart Dallas
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/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] form handling

2011-08-11 Thread Ken Robinson

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


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



[PHP] Fwd: i, em, strong and b in html5h

2011-08-11 Thread Grega Leskovšek
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?" Np, my name is Paris. I
live in Ljubljana.Warning! This is a nudistic
beach

: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
The Titanic sails.The design needs a bit more ooh la laGluteus maximus

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

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

 is deprecated, use  instead and  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

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



Re: [PHP] Problem with inserting numbers...

2011-08-11 Thread Jim Lucas
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.



You should see...

INSERT INTO Test (fullnumber) VALUES ('907-200-') 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 1 re-indexes for 1 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

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



Re: [PHP] form handling

2011-08-11 Thread Chris Stinemetz
>
> If the two forms call the same script that's fine.  If not, that will work
> too.  Just realize that the inputs from one form will NOT be returned to the
> script when the submit is used from the other form.
>

Jim,

This is what I am trying to do. One submit button for both forms going
to the same destination.

The only reason I am doing this is because I can't figure out why my
ajax for my select menus is altering my tinyMCE textarea box.

Ultimately if I can figure out how to control the ajax within the div
container as I showed in a previous email I would be able to just use
one form. any ideas??

Thanks,

Chris

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



Re: [PHP] form handling

2011-08-11 Thread Jim Giner
I'm thinking that Chris means that he has a 'page' designed that utilizes 
two form tags for functionally different sets of input fields.  The answer 
Chris is that a page can have many forms and whether or not they trigger the 
same script upon submit or not doesn't matter.  Go ahead!

My sample html:

blah
blah
head
script
/script
style
/style
/head
body
form
inputs
/form
blah
blah
form
inputs
/form
/body
/html

If the two forms call the same script that's fine.  If not, that will work 
too.  Just realize that the inputs from one form will NOT be returned to the 
script when the submit is used from the other form. 



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



Re: [PHP] form handling

2011-08-11 Thread Jim Giner

Jim,

This is what I am trying to do. One submit button for both forms going
to the same destination.

The only reason I am doing this is because I can't figure out why my
ajax for my select menus is altering my tinyMCE textarea box.

Ultimately if I can figure out how to control the ajax within the div
container as I showed in a previous email I would be able to just use
one form. any ideas??

Thanks,

Chris


Chris,
By definition, a 'submit' button submits a form.  Not 2 forms.  Each form 
has to have it's own form. It is not feasible to submit two forms - since 
the conversation from your client pc is going to be garbled even if you 
could (JS?) do the second submit.  One transactiion is going to answer your 
client and then the other is going to wipe it out with its respone.


I don't think you have ot separate your forms becuase they are in separate 
divs.  I could be wrong - never tried it. 




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



Re: [PHP] form handling

2011-08-11 Thread Chris Stinemetz
> Chris,
> By definition, a 'submit' button submits a form.  Not 2 forms.  Each form
> has to have it's own form. It is not feasible to submit two forms - since
> the conversation from your client pc is going to be garbled even if you
> could (JS?) do the second submit.  One transactiion is going to answer your
> client and then the other is going to wipe it out with its respone.
>
> I don't think you have ot separate your forms becuase they are in separate
> divs.  I could be wrong - never tried it.
>
>

I didn't think it was possible either. I will play around with the div
container and ajax some more tonight. Hope I will be able to figure it
out. Is it possible to place a div within the form to only affect the
select tags?

Thanks,

Chris

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



Re: [PHP] form handling

2011-08-11 Thread Bastien


On 2011-08-11, at 9:13 PM, "Jim Giner"  wrote:

> Jim,
> 
> This is what I am trying to do. One submit button for both forms going
> to the same destination.
> 
> The only reason I am doing this is because I can't figure out why my
> ajax for my select menus is altering my tinyMCE textarea box.
> 
> Ultimately if I can figure out how to control the ajax within the div
> container as I showed in a previous email I would be able to just use
> one form. any ideas??
> 
> Thanks,
> 
> Chris
> 
> 
> Chris,
> By definition, a 'submit' button submits a form.  Not 2 forms.  Each form has 
> to have it's own form. It is not feasible to submit two forms - since the 
> conversation from your client pc is going to be garbled even if you could 
> (JS?) do the second submit.  One transactiion is going to answer your client 
> and then the other is going to wipe it out with its respone.
> 
> I don't think you have ot separate your forms becuase they are in separate 
> divs.  I could be wrong - never tried it. 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

I would bet it's the quotes screwing up the js. Can / are you escaping that 
variable when ajaxing it back?

Bastien Koert
905-904-0334



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



Re: [PHP] form handling

2011-08-11 Thread Chris Stinemetz
>
> I would bet it's the quotes screwing up the js. Can / are you escaping that 
> variable when ajaxing it back?
>
> Bastien Koert
> 905-904-0334
>

I found a way to make the ajax work with one form. I removed the table
and the ajax worked just fine. Aparently you can't embed div
containers within a table without affecting the whole table. At least
that is what I found out tonight. Please correct me if I am wrong.

Chris

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