php-general Digest 7 Apr 2011 04:17:02 -0000 Issue 7261

Topics (messages 312279 through 312288):

Re: Newbi Question with calculate
        312279 by: Jim Giner
        312280 by: Me
        312281 by: Silvio Siefke

File Upload Problem
        312282 by: tedd
        312283 by: Bastien Koert
        312284 by: Daniel Brown

openssl question
        312285 by: Kai Renz

Re: Ranges for case statement and a WTF moment.
        312286 by: Shawn McKenzie
        312287 by: David Harkness

the best 1 book for php
        312288 by: Kirk Bailey

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 ---
I think you want to use the FOR loop to process each record in your table. 
You query (?) the table and then process each row in the result using the 
FOR and all your calculations on each one.  Look up FOR.
"Silvio Siefke" <[email protected]> wrote in message 
news:[email protected]...
> Hello,
>
>
> i have write a script for my Stock portfolio and now im not really find
> something which can me help.
>
> In the table php calculate me the Present Value and the Percent with
> this code:
>
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> <?php
> //Quantity
> $ABEI = 240;
>
> //Buy Quote
> $KKBEI = 41.31;
>
> //Buy Balance
> $KWBEI = 9914.40;
>
> //calculate
> include("../inc/quote.php"); // Yahoo Quotes
> $BEIERG = $KKBEI*$ABEI; // Buy Balance
> $BEIDW = $BEIQuote['last']*$ABEI; // Present Value
> $BEIAEN1 = $BEIQuote['last']-$KKBEI; // Quote Win
> $BEIAEN = $BEIAEN1*100/$KKBEI; //Percent Win
> ?>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>
> Is it possible to apply logic to the whole table? Or do I write for each
> additional item the same source code?
>
>
> It were nice someone has a Tip for me? Thank u.
>
>
> Silvio 



--- End Message ---
--- Begin Message ---
I will give you a mysql example.

Apply the logic to the table during the query so you can just loop over the results like such.

$ABEI=12;
$query = ' select last * '.$ABEI.' AS resulta From table';






Sent via DROID on Verizon Wireless

-----Original message-----
From: Silvio Siefke <[email protected]>
To: [email protected]
Sent: Wed, Apr 6, 2011 12:50:20 GMT+00:00
Subject: [PHP] Newbi Question with calculate

Hello,


i have write a script for my Stock portfolio and now im not really find
something which can me help.

In the table php calculate me the Present Value and the Percent with
this code:

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<?php
//Quantity
$ABEI = 240;

//Buy Quote
$KKBEI = 41.31;

//Buy Balance
$KWBEI = 9914.40;

//calculate
include("../inc/quote.php"); // Yahoo Quotes
$BEIERG = $KKBEI*$ABEI; // Buy Balance
$BEIDW = $BEIQuote['last']*$ABEI; // Present Value
$BEIAEN1 = $BEIQuote['last']-$KKBEI; // Quote Win
$BEIAEN = $BEIAEN1*100/$KKBEI; //Percent Win
?>


Is it possible to apply logic to the whole table? Or do I write for each
additional item the same source code?


It were nice someone has a Tip for me? Thank u.


Silvio

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



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

sorry i has not correct write.

The example when is finish can see at
http://silviosiefke.de/finance/stock/stock.php

For this i not use a mysql Database, its normal not so much at data.

I have write the source as Text Files:

http://silviosiefke.de/finance/finished/txt/index.txt
- That is the Start Page.

The included Files:
http://silviosiefke.de/finance/finished/txt/include.txt -> Yahoo API
http://silviosiefke.de/finance/finished/txt/quote.txt -> Yahoo Symbols
http://silviosiefke.de/finance/finished/txt/variable.txt -> Calculate

If I calculate all the shares in my portfolio, then I have to create for
each share a file variable.php. Thats little long, is not the problem i
make it, but i think there is a chance to use the file variable.php at
moment for all what come in my portfolio?

For example at Moment i calculate Beiersdorf AG, the next in Portfolio
is Deutsche Bank AG. Now i must write a new variable.php for Deutsche
Bank. Or is there a chance that i can write one variable.php for all
Shares what i take in the portfolio.

Sorry for my english, i know its not perfect. Hope all can understand
what i mean. I learn every day and i find good that i not must use
google since few weeks.


Thanks for help, have nice day at all.


Regards
Silvio

--- End Message ---
--- Begin Message ---
Hi gang:

I wrote a simple script to upload image files from my desktop to a server -- the exact same code works on two servers, but fails on a third.

I suspect there is something set different between the servers, but I can't find it.

Oddly enough, I can upload image files directly to the database, but not to the file system.

What could be wrong? What should I be looking for?

Cheers,

tedd

--
-------
http://sperling.com/

--- End Message ---
--- Begin Message ---
On Wed, Apr 6, 2011 at 1:10 PM, tedd <[email protected]> wrote:
> Hi gang:
>
> I wrote a simple script to upload image files from my desktop to a server --
> the exact same code works on two servers, but fails on a third.
>
> I suspect there is something set different between the servers, but I can't
> find it.
>
> Oddly enough, I can upload image files directly to the database, but not to
> the file system.
>
> What could be wrong? What should I be looking for?
>
> Cheers,
>
> tedd
>
> --
> -------
> http://sperling.com/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

check out the max post size

-- 

Bastien

Cat, the other other white meat

--- End Message ---
--- Begin Message ---
On Wed, Apr 6, 2011 at 13:10, tedd <[email protected]> wrote:
> Hi gang:
>
> I wrote a simple script to upload image files from my desktop to a server --
> the exact same code works on two servers, but fails on a third.
>
> I suspect there is something set different between the servers, but I can't
> find it.
>
> Oddly enough, I can upload image files directly to the database, but not to
> the file system.
>
> What could be wrong? What should I be looking for?

    Are file uploads enabled and is the size of the file less than the
upload size limitation?  Is the disk or partition to which the
temporary files are being uploaded out of space, whereas the database
- perhaps on a different physical disk or partition - still has
sufficient free space?  Are you sure the user as which the web server
(presumably Apache) runs has permission to write to the temporary and
target directory?  Is the account near or at its disk quota?

-- 
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/

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

i try to create a self signed certificate using this code:

<?php

        if(!isset($_GET['password']))
        {
                echo "Error Code: 1";
                exit(1);
        }

        
        if($_GET['password'] == "")
        {
                echo "Error Code 2";
                exit(1);
        }       
        
        $password = mysql_real_escape_string($_GET['password']);

        
        
$dn = array(
    "countryName" => "DE",
    "stateOrProvinceName" => "test",
    "localityName" => "test",
    "organizationName" => "test",
    "organizationalUnitName" => "test",
    "commonName" => "test",
    "emailAddress" => "[email protected]"
);


$privkey = openssl_pkey_new();


$csr = openssl_csr_new($dn, $privkey);


$sscert = openssl_csr_sign($csr, null, $privkey, 365);

openssl_csr_export($csr, $csrout) and var_dump($csrout);
openssl_x509_export($sscert, $certout) and var_dump($certout);
openssl_pkey_export($privkey, $pkeyout, $password) and var_dump($pkeyout);

while (($e = openssl_error_string()) !== false) {
    echo $e . "\n";
}

?>


But all i get is this:
Warning: openssl_csr_sign() [function.openssl-csr-sign]: cannot get
CSR from parameter 1 in
C:\xampp\htdocs\test\admin\create_self_signed_crt_action.php on line
42
Warning: openssl_csr_export() expects parameter 1 to be resource,
boolean given in
C:\xampp\htdocs\test\admin\create_self_signed_crt_action.php on line
51
Warning: openssl_x509_export() [function.openssl-x509-export]: cannot
get cert from parameter 1 in
C:\xampp\htdocs\test\admin\create_self_signed_crt_action.php on line
52
Warning: openssl_pkey_export() [function.openssl-pkey-export]: cannot
get key from parameter 1 in
C:\xampp\htdocs\test\admin\create_self_signed_crt_action.php on line
53
error:02001003:system library:fopen:No such process error:2006D080:BIO
routines:BIO_new_file:no such file error:0E064002:configuration file
routines:CONF_load:system lib error:02001003:system library:fopen:No
such process error:2006D080:BIO routines:BIO_new_file:no such file
error:0E064002:configuration file routines:CONF_load:system lib
error:02001003:system library:fopen:No such process error:2006D080:BIO
routines:BIO_new_file:no such file error:0E064002:configuration file
routines:CONF_load:system lib error:02001003:system library:fopen:No
such process error:2006D080:BIO routines:BIO_new_file:no such file
error:0E064002:configuration file routines:CONF_load:system lib

I'm using a windows box with xampp installed.

regards.

--- End Message ---
--- Begin Message ---
On 04/05/2011 10:28 AM, Richard Quadling wrote:
> Hi.
> 
> I just wanted to quickly see if PHP supported ranges in its
> switch/case statement (http://en.wikipedia.org/wiki/Ellipsis)
> 
> <?php
> $s = intval(date('s'));
> switch($s)
>       {
>       case 0...9   : echo 'Between 0 and 9'; break;
>       case 10...19 : echo 'Between 10 and 19'; break;
>       case 20...29 : echo 'Between 20 and 29'; break;
>       case 30...39 : echo 'Between 30 and 39'; break;
>       case 40...49 : echo 'Between 40 and 49'; break;
>       case 50...59 : echo 'Between 50 and 59'; break;
>       default      : echo 'Unknown : ', $s;
>       }
> ?>
> 
> Completely unexpectedly, the above code runs but produces the wrong output.

FYI. My first inclination would have been:

switch(true) {
   case in_array($s, range(0, 9)): echo "0 - 9"; break;
}

But it's messy.

-- 
Thanks!
-Shawn
http://www.spidean.com

--- End Message ---
--- Begin Message ---
On Tue, Apr 5, 2011 at 8:28 AM, Richard Quadling <[email protected]>wrote:

> php -r "var_dump(10...19);"
>
> Interesting output ...
>
> string(6) "100.19"
>
> And that took me a little while to work out.
>
> It's all to do with PHP's type juggling.
>
> 10...19
>
> What I'm not sure is why the middle empty string is output as 0.
>
> "10" . . ".19" becomes "10" . "0" . ".19" which becomes "100.19"
>

My guess is that PHP parses this as

    10<decimal-point> <dot-operator> <decimal-point>19

Because the dot operator requires strings, PHP converts both numbers to
strings as

    '10' <dot-operator> '0.19'

which becomes your

    100.19

You can see this with

    php > echo (string) 10.
    10
    php > echo (string) .19
    0.19

David

--- End Message ---
--- Begin Message ---
If I only had 1 book on php, what would it be?

--
end

Very Truly yours,
                 - Kirk Bailey,
                   Largo Florida

                       kniht
                      +-----+
                      | BOX |
                      +-----+
                       think


--- End Message ---

Reply via email to