php-windows Digest 10 Dec 2008 15:45:15 -0000 Issue 3544

Topics (messages 29086 through 29095):

there must be better way to handle "Null" undefined variables
        29086 by: Fred Silsbee
        29087 by: justin
        29088 by: Fred Silsbee
        29089 by: Daniel Brown
        29090 by: Fred Silsbee
        29091 by: Daniel Brown
        29092 by: James Crow
        29093 by: Fred Silsbee
        29094 by: Niel Archer

Re: Problem with GD2 & PHP
        29095 by: Gunawan

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 ---
Problem with the code below

Works perfectly under Linux Fedora 9 however

Under windows, the first page has an error <br /><b>Notice</b>:  Undefined 
variable: ExercisePrice in <b>C:\Inetpub\wwwroot\new_black_scholes.php</b> on 
line <b>198</b><br />

stuck in the entry slot for every variable.

I did correct the first slot with some PHP code!

Is there a better way?


<?php
define( "ITMAX",100);
define( "EPS",3.0e-7);
    // If the submit button has been pressed
    if (isset($_POST['reset']))
    {

    $m_s = 100.;
    $m_e = 100.;
    $m_rf = .12;
    $m_sigma = .1;
    $m_time = 365.;
    Black_Scholes_Main($m_s, $m_e, $m_rf, $m_sigma,$m_time, $m_c, $m_p, 
$m_deltacalls, $m_deltaputs);
    $StockPrice = $m_s;
    $ExercisePrice = $m_e;
    $RiskFreeRateInterest = $m_rf;
    $InstantaneousVarianceRateStocksReturn = $m_sigma;
    $TimetoExpirationOption = $m_time;
    $ValueCallOption = $m_c;
    $ValuePutOption = $m_p;
    $DeltaCalls = $m_deltacalls;
    $DeltaPuts = $m_deltaputs;
    }
    elseif (isset($_POST['submit']))
    {
    $m_s = $_POST['StockPrice'];
    $m_e = $_POST['ExercisePrice'];
    $m_rf = $_POST['RiskFreeRateInterest'];
    $m_sigma = $_POST['InstantaneousVarianceRateStocksReturn'];
    $m_time = $_POST['TimetoExpirationOption'];
    Black_Scholes_Main($m_s, $m_e, $m_rf, $m_sigma,$m_time, $m_c, $m_p, 
$m_deltacalls, $m_deltaputs);
    $StockPrice = $m_s;
    $ExercisePrice = $m_e;
    $RiskFreeRateInterest = $m_rf;
    $InstantaneousVarianceRateStocksReturn = $m_sigma;
    $TimetoExpirationOption = $m_time;
    $ValueCallOption = $m_c;
    $ValuePutOption = $m_p;
    $DeltaCalls = $m_deltacalls;
    $DeltaPuts = $m_deltaputs;
    }
function Black_Scholes_Main($m_s, $m_e, $m_rf, $m_sigma, $m_time, &$m_c, &$m_p, 
&$m_deltacalls, &$m_deltaputs) {
        $m_c = black_scholes($m_s,  $m_e,  $m_rf,  $m_sigma,  $m_time/365., 
$nd1, $nd2);
        $m_p = $m_e / pow(1.+$m_rf, $m_time/365.) - $m_s + $m_c;
        $m_deltacalls = $nd1;
        $m_deltaputs = $nd1 - 1.;
}
function black_scholes( $s,  $e,  $rf,  $sigma,  $time, &$nd1, &$nd2) {
        $num = log($s/$e)+$time*($rf+.5*$sigma*$sigma);
        $d1 = $num/($sigma*sqrt($time));
        $d2 = $d1 - $sigma*sqrt($time);
        $c = $s*myerf($d1) - $e * myerf($d2) * exp(-$rf*$time);
        $nd1 = myerf($d1);
        $nd2 = myerf($d2);

        return $c;
}
function gammln($xx)
{
        $cof=array(76.18009173,-86.50532033,24.01409822,
                -1.231739516,0.120858003e-2,-0.536382e-5);

        $x=$xx-1.0;
        $tmp=$x+5.5;
        $tmp -= ($x+0.5)*log($tmp);
        $ser=1.0;
        for ($j=0;$j<=5;$j++) {
                $x += 1.0;
                $ser += $cof[$j]/$x;
        }
        return -$tmp+log(2.50662827465*$ser);
}

function gser(  &$gamser,  $a,  $x, &$gln)
{

        $gln=gammln($a);
        if ($x <= 0.0) {
                if ($x < 0.0) echo "x less than 0 in routine GSER";
                $gamser=0.0;
                return;
        } else {
                $ap=$a;
                $sum=1.0/$a;
        $del=$sum;
                for ($n=1;$n<=ITMAX;$n++) {
                        $ap += 1.0;
                        $del *= $x/$ap;
                        $sum += $del;
                        if (abs($del) < abs($sum)*EPS) {
                                $gamser=$sum*exp(-$x+$a*log($x)-($gln));
                                return;
                        }
                }
                echo "a=$a too large, ITMAX = $itmax too small in routine 
GSER<br />";
                return;
        }
}


function gcf( &$gammcf,$a,$x,&$gln)
{
        $gold=0.0;
        $fac=1.0;
        $b1=1.0;
        $b0=0.0;
        $a0=1.0;

        $gln=gammln($a);
        $a1=$x;
        for ($n=1;$n<=ITMAX;$n++) {
                $an=(double) $n;
                $ana=$an-$a;
                $a0=($a1+$a0*$ana)*$fac;
                $b0=($b1+$b0*$ana)*$fac;
                $anf=$an*$fac;
                $a1=$x*$a0+$anf*$a1;
                $b1=$x*$b0+$anf*$b1;
                if ($a1) {
                        $fac=1.0/$a1;
                        $g=$b1*$fac;
                        if (abs(($g-$gold)/$g) < EPS) {
                                $gammcf=exp(-$x+$a*log($x)-($gln))*$g;
                                return;
                        }
                        $gold=$g;
                }
        }
        echo "a too large, ITMAX too small in routine GCF<br />";
}
function gammp($a,$x)
{

        if ($x < 0.0 || $a <= 0.0) {
                echo "Invalid arguments in routine GAMMP<br />";
                return 0.;
        }
        if ($x < ($a+1.0)) {
                gser($gamser,$a,$x,$gln);
                return $gamser;
        } else {
                gcf($gammcf,$a,$x,$gln);
                return 1.0-$gammcf;
        }
}

function gammq($a,$x)
{

        if ($x < 0.0 || $a <= 0.0) echo "Invalid arguments in routine GAMMQ<br 
/>";
        if ($x < ($a+1.0)) {
                gser($gamser,$a,$x,$gln);
                return 1.0-$gamser;
        } else {
                gcf($gammcf,$a,$x,$gln);
                return $gammcf;
        }
}
function erfc($x)
{

        return $x < 0.0 ? 1.0+gammp(0.5,$x*$x) : gammq(0.5,$x*$x);
}
function erf($x)
{

        return $x < 0.0 ? -gammp(0.5,$x*$x) : gammp(0.5,$x*$x);
}
function myerf($argin) {
       return .5*(1.+erf($argin/sqrt(2.0)));
}

?>

<form action="new_black_scholes.php" method="post">
    <p>
        Black Scholes Option Price Calculator:<br />
            temp website under Redhat Fedora 9 Linux:<br />
            the first 5 boxes require input(try 100. 100. .12 .1 365.):<br />
    </p>
    <p>
        StockPrice (required):<br />
        <input type="text" size="20" maxlength="40" name="StockPrice"
        value="<?php
    if (IsSet($StockPrice))
    {
        echo $StockPrice;
    }
    else
    {
        echo " ";
    }
    ?>" />
    </p>
    <p>
        ExercisePrice (required):<br />
        <input type="text" size="20" maxlength="40" name="ExercisePrice"
        value="<?php echo $ExercisePrice; ?>" />
</p>
    <p>
        Risk Free Rate of Interest(required):<br />
        <input type="text" size="20" maxlength="40" name="RiskFreeRateInterest"
        value="<?php echo $RiskFreeRateInterest; ?>" />
    </p>
    <p>
        Instantaneous Variance Rate of Stock's Return (required):<br />
        <input type="text" size="20" maxlength="40" 
name="InstantaneousVarianceRateStocksReturn"
        value="<?php echo $InstantaneousVarianceRateStocksReturn; ?>" />
</p>
    <p>
        Time to Expiration of the Option(days) (required):<br />
        <input type="text" size="20" maxlength="40" 
name="TimetoExpirationOption"
        value="<?php echo $TimetoExpirationOption; ?>" />
</p>
    <p>
        Values of the Call Option :<br />
        <input type="text" size="20" maxlength="40"  name="ValueCallOption"
            VALUE="<?php echo $ValueCallOption; ?>" />
</p>
</p>
    <p>
        Values of the Put option :<br />
        <input type="text" size="20" maxlength="40"  name="ValuePutOption"
            VALUE="<?php echo $ValuePutOption; ?>" />
</p>
    <p>
        Delta(calls):<br />
        <input type="text" size="20" maxlength="40"  name="DeltaCalls"
            VALUE="<?php echo $DeltaCalls; ?>" />
</p>
    <p>
        Delta(puts):<br />
        <input type="text" size="20" maxlength="40"  name="DeltaPuts"
            VALUE="<?php echo $DeltaPuts; ?>" />
</p>
    <button type="submit" name = "submit" value="Calculate!"
    style="color:maroon font:18pt Courier; font-weight:bold ">Calculate
    </button>
    <button type="submit" name = "reset" value="Demo!"
    style="color:red font:18pt Courier; font-weight:bold ">Demo
    </button>
</form>





      


--- End Message ---
--- Begin Message --- This is more a matter of a php.ini setting. Check the values of error_reporting in both your php.ini on the Windows and Linux boxes. My guess is your windows value is E_ALL.

-Justin

Fred Silsbee wrote:
Problem with the code below

Works perfectly under Linux Fedora 9 however

Under windows, the first page has an error <br /><b>Notice</b>:  Undefined variable: ExercisePrice in 
<b>C:\Inetpub\wwwroot\new_black_scholes.php</b> on line <b>198</b><br />

stuck in the entry slot for every variable.

I did correct the first slot with some PHP code!

Is there a better way?


<?php
define( "ITMAX",100);
define( "EPS",3.0e-7);
    // If the submit button has been pressed
    if (isset($_POST['reset']))
    {

    $m_s = 100.;
    $m_e = 100.;
    $m_rf = .12;
    $m_sigma = .1;
    $m_time = 365.;
    Black_Scholes_Main($m_s, $m_e, $m_rf, $m_sigma,$m_time, $m_c, $m_p, 
$m_deltacalls, $m_deltaputs);
    $StockPrice = $m_s;
    $ExercisePrice = $m_e;
    $RiskFreeRateInterest = $m_rf;
    $InstantaneousVarianceRateStocksReturn = $m_sigma;
    $TimetoExpirationOption = $m_time;
    $ValueCallOption = $m_c;
    $ValuePutOption = $m_p;
    $DeltaCalls = $m_deltacalls;
    $DeltaPuts = $m_deltaputs;
    }
    elseif (isset($_POST['submit']))
    {
    $m_s = $_POST['StockPrice'];
    $m_e = $_POST['ExercisePrice'];
    $m_rf = $_POST['RiskFreeRateInterest'];
    $m_sigma = $_POST['InstantaneousVarianceRateStocksReturn'];
    $m_time = $_POST['TimetoExpirationOption'];
    Black_Scholes_Main($m_s, $m_e, $m_rf, $m_sigma,$m_time, $m_c, $m_p, 
$m_deltacalls, $m_deltaputs);
    $StockPrice = $m_s;
    $ExercisePrice = $m_e;
    $RiskFreeRateInterest = $m_rf;
    $InstantaneousVarianceRateStocksReturn = $m_sigma;
    $TimetoExpirationOption = $m_time;
    $ValueCallOption = $m_c;
    $ValuePutOption = $m_p;
    $DeltaCalls = $m_deltacalls;
    $DeltaPuts = $m_deltaputs;
    }
function Black_Scholes_Main($m_s, $m_e, $m_rf, $m_sigma, $m_time, &$m_c, &$m_p, 
&$m_deltacalls, &$m_deltaputs) {
        $m_c = black_scholes($m_s,  $m_e,  $m_rf,  $m_sigma,  $m_time/365., 
$nd1, $nd2);
        $m_p = $m_e / pow(1.+$m_rf, $m_time/365.) - $m_s + $m_c;
        $m_deltacalls = $nd1;
        $m_deltaputs = $nd1 - 1.;
}
function black_scholes( $s,  $e,  $rf,  $sigma,  $time, &$nd1, &$nd2) {
        $num = log($s/$e)+$time*($rf+.5*$sigma*$sigma);
        $d1 = $num/($sigma*sqrt($time));
        $d2 = $d1 - $sigma*sqrt($time);
        $c = $s*myerf($d1) - $e * myerf($d2) * exp(-$rf*$time);
        $nd1 = myerf($d1);
        $nd2 = myerf($d2);

        return $c;
}
function gammln($xx)
{
        $cof=array(76.18009173,-86.50532033,24.01409822,
                -1.231739516,0.120858003e-2,-0.536382e-5);

        $x=$xx-1.0;
        $tmp=$x+5.5;
        $tmp -= ($x+0.5)*log($tmp);
        $ser=1.0;
        for ($j=0;$j<=5;$j++) {
                $x += 1.0;
                $ser += $cof[$j]/$x;
        }
        return -$tmp+log(2.50662827465*$ser);
}

function gser(  &$gamser,  $a,  $x, &$gln)
{

        $gln=gammln($a);
        if ($x <= 0.0) {
                if ($x < 0.0) echo "x less than 0 in routine GSER";
                $gamser=0.0;
                return;
        } else {
                $ap=$a;
                $sum=1.0/$a;
        $del=$sum;
                for ($n=1;$n<=ITMAX;$n++) {
                        $ap += 1.0;
                        $del *= $x/$ap;
                        $sum += $del;
                        if (abs($del) < abs($sum)*EPS) {
                                $gamser=$sum*exp(-$x+$a*log($x)-($gln));
                                return;
                        }
                }
                echo "a=$a too large, ITMAX = $itmax too small in routine GSER<br 
/>";
                return;
        }
}


function gcf( &$gammcf,$a,$x,&$gln)
{
        $gold=0.0;
        $fac=1.0;
        $b1=1.0;
        $b0=0.0;
        $a0=1.0;

        $gln=gammln($a);
        $a1=$x;
        for ($n=1;$n<=ITMAX;$n++) {
                $an=(double) $n;
                $ana=$an-$a;
                $a0=($a1+$a0*$ana)*$fac;
                $b0=($b1+$b0*$ana)*$fac;
                $anf=$an*$fac;
                $a1=$x*$a0+$anf*$a1;
                $b1=$x*$b0+$anf*$b1;
                if ($a1) {
                        $fac=1.0/$a1;
                        $g=$b1*$fac;
                        if (abs(($g-$gold)/$g) < EPS) {
                                $gammcf=exp(-$x+$a*log($x)-($gln))*$g;
                                return;
                        }
                        $gold=$g;
                }
        }
        echo "a too large, ITMAX too small in routine GCF<br />";
}
function gammp($a,$x)
{

        if ($x < 0.0 || $a <= 0.0) {
                echo "Invalid arguments in routine GAMMP<br />";
                return 0.;
        }
        if ($x < ($a+1.0)) {
                gser($gamser,$a,$x,$gln);
                return $gamser;
        } else {
                gcf($gammcf,$a,$x,$gln);
                return 1.0-$gammcf;
        }
}

function gammq($a,$x)
{

        if ($x < 0.0 || $a <= 0.0) echo "Invalid arguments in routine GAMMQ<br 
/>";
        if ($x < ($a+1.0)) {
                gser($gamser,$a,$x,$gln);
                return 1.0-$gamser;
        } else {
                gcf($gammcf,$a,$x,$gln);
                return $gammcf;
        }
}
function erfc($x)
{

        return $x < 0.0 ? 1.0+gammp(0.5,$x*$x) : gammq(0.5,$x*$x);
}
function erf($x)
{

        return $x < 0.0 ? -gammp(0.5,$x*$x) : gammp(0.5,$x*$x);
}
function myerf($argin) {
       return .5*(1.+erf($argin/sqrt(2.0)));
}

?>

<form action="new_black_scholes.php" method="post">
    <p>
        Black Scholes Option Price Calculator:<br />
            temp website under Redhat Fedora 9 Linux:<br />
            the first 5 boxes require input(try 100. 100. .12 .1 365.):<br />
    </p>
    <p>
        StockPrice (required):<br />
        <input type="text" size="20" maxlength="40" name="StockPrice"
        value="<?php
    if (IsSet($StockPrice))
    {
        echo $StockPrice;
    }
    else
    {
        echo " ";
    }
    ?>" />
    </p>
    <p>
        ExercisePrice (required):<br />
        <input type="text" size="20" maxlength="40" name="ExercisePrice"
        value="<?php echo $ExercisePrice; ?>" />
</p>
    <p>
        Risk Free Rate of Interest(required):<br />
        <input type="text" size="20" maxlength="40" name="RiskFreeRateInterest"
        value="<?php echo $RiskFreeRateInterest; ?>" />
    </p>
    <p>
        Instantaneous Variance Rate of Stock's Return (required):<br />
        <input type="text" size="20" maxlength="40" 
name="InstantaneousVarianceRateStocksReturn"
        value="<?php echo $InstantaneousVarianceRateStocksReturn; ?>" />
</p>
    <p>
        Time to Expiration of the Option(days) (required):<br />
        <input type="text" size="20" maxlength="40" 
name="TimetoExpirationOption"
        value="<?php echo $TimetoExpirationOption; ?>" />
</p>
    <p>
        Values of the Call Option :<br />
        <input type="text" size="20" maxlength="40"  name="ValueCallOption"
            VALUE="<?php echo $ValueCallOption; ?>" />
</p>
</p>
    <p>
        Values of the Put option :<br />
        <input type="text" size="20" maxlength="40"  name="ValuePutOption"
            VALUE="<?php echo $ValuePutOption; ?>" />
</p>
    <p>
        Delta(calls):<br />
        <input type="text" size="20" maxlength="40"  name="DeltaCalls"
            VALUE="<?php echo $DeltaCalls; ?>" />
</p>
    <p>
        Delta(puts):<br />
        <input type="text" size="20" maxlength="40"  name="DeltaPuts"
            VALUE="<?php echo $DeltaPuts; ?>" />
</p>
    <button type="submit" name = "submit" value="Calculate!"
    style="color:maroon font:18pt Courier; font-weight:bold ">Calculate
    </button>
    <button type="submit" name = "reset" value="Demo!"
    style="color:red font:18pt Courier; font-weight:bold ">Demo
    </button>
</form>








--- End Message ---
--- Begin Message ---
YES! I am working on another php script to connect to MS SQL Server!

I need all the clues I can get to get it working!

Great clues searching php.net site!

Meanwhile I get the hokey error in my boxes

I did fix the problem but my code is gloating!





--- On Mon, 12/8/08, justin <[EMAIL PROTECTED]> wrote:

> From: justin <[EMAIL PROTECTED]>
> Subject: Re: [PHP-WIN] there must be better way to handle "Null" undefined 
> variables
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Date: Monday, December 8, 2008, 5:00 PM
> This is more a matter of a php.ini setting.  Check the
> values of 
> error_reporting in both your php.ini on the Windows and
> Linux boxes.   
> My guess is your windows value is E_ALL.
> 
> -Justin
> 
> Fred Silsbee wrote:
> > Problem with the code below
> >
> > Works perfectly under Linux Fedora 9 however
> >
> > Under windows, the first page has an error <br
> /><b>Notice</b>:  Undefined variable:
> ExercisePrice in
> <b>C:\Inetpub\wwwroot\new_black_scholes.php</b>
> on line <b>198</b><br />
> >
> > stuck in the entry slot for every variable.
> >
> > I did correct the first slot with some PHP code!
> >
> > Is there a better way?
> >
> >
> > <?php
> > define( "ITMAX",100);
> > define( "EPS",3.0e-7);
> >     // If the submit button has been pressed
> >     if (isset($_POST['reset']))
> >     {
> >
> >     $m_s = 100.;
> >     $m_e = 100.;
> >     $m_rf = .12;
> >     $m_sigma = .1;
> >     $m_time = 365.;
> >     Black_Scholes_Main($m_s, $m_e, $m_rf,
> $m_sigma,$m_time, $m_c, $m_p, $m_deltacalls, $m_deltaputs);
> >     $StockPrice = $m_s;
> >     $ExercisePrice = $m_e;
> >     $RiskFreeRateInterest = $m_rf;
> >     $InstantaneousVarianceRateStocksReturn = $m_sigma;
> >     $TimetoExpirationOption = $m_time;
> >     $ValueCallOption = $m_c;
> >     $ValuePutOption = $m_p;
> >     $DeltaCalls = $m_deltacalls;
> >     $DeltaPuts = $m_deltaputs;
> >     }
> >     elseif (isset($_POST['submit']))
> >     {
> >     $m_s = $_POST['StockPrice'];
> >     $m_e = $_POST['ExercisePrice'];
> >     $m_rf = $_POST['RiskFreeRateInterest'];
> >     $m_sigma =
> $_POST['InstantaneousVarianceRateStocksReturn'];
> >     $m_time =
> $_POST['TimetoExpirationOption'];
> >     Black_Scholes_Main($m_s, $m_e, $m_rf,
> $m_sigma,$m_time, $m_c, $m_p, $m_deltacalls, $m_deltaputs);
> >     $StockPrice = $m_s;
> >     $ExercisePrice = $m_e;
> >     $RiskFreeRateInterest = $m_rf;
> >     $InstantaneousVarianceRateStocksReturn = $m_sigma;
> >     $TimetoExpirationOption = $m_time;
> >     $ValueCallOption = $m_c;
> >     $ValuePutOption = $m_p;
> >     $DeltaCalls = $m_deltacalls;
> >     $DeltaPuts = $m_deltaputs;
> >     }
> > function Black_Scholes_Main($m_s, $m_e, $m_rf,
> $m_sigma, $m_time, &$m_c, &$m_p, &$m_deltacalls,
> &$m_deltaputs) {
> >         $m_c = black_scholes($m_s,  $m_e,  $m_rf, 
> $m_sigma,  $m_time/365., $nd1, $nd2);
> >         $m_p = $m_e / pow(1.+$m_rf, $m_time/365.) -
> $m_s + $m_c;
> >         $m_deltacalls = $nd1;
> >         $m_deltaputs = $nd1 - 1.;
> > }
> > function black_scholes( $s,  $e,  $rf,  $sigma, 
> $time, &$nd1, &$nd2) {
> >         $num =
> log($s/$e)+$time*($rf+.5*$sigma*$sigma);
> >         $d1 = $num/($sigma*sqrt($time));
> >         $d2 = $d1 - $sigma*sqrt($time);
> >         $c = $s*myerf($d1) - $e * myerf($d2) *
> exp(-$rf*$time);
> >         $nd1 = myerf($d1);
> >         $nd2 = myerf($d2);
> >
> >         return $c;
> > }
> > function gammln($xx)
> > {
> >        
> $cof=array(76.18009173,-86.50532033,24.01409822,
> >                
> -1.231739516,0.120858003e-2,-0.536382e-5);
> >
> >         $x=$xx-1.0;
> >         $tmp=$x+5.5;
> >         $tmp -= ($x+0.5)*log($tmp);
> >         $ser=1.0;
> >         for ($j=0;$j<=5;$j++) {
> >                 $x += 1.0;
> >                 $ser += $cof[$j]/$x;
> >         }
> >         return -$tmp+log(2.50662827465*$ser);
> > }
> >
> > function gser(  &$gamser,  $a,  $x, &$gln)
> > {
> >
> >         $gln=gammln($a);
> >         if ($x <= 0.0) {
> >                 if ($x < 0.0) echo "x less
> than 0 in routine GSER";
> >                 $gamser=0.0;
> >                 return;
> >         } else {
> >                 $ap=$a;
> >                 $sum=1.0/$a;
> >         $del=$sum;
> >                 for ($n=1;$n<=ITMAX;$n++) {
> >                         $ap += 1.0;
> >                         $del *= $x/$ap;
> >                         $sum += $del;
> >                         if (abs($del) <
> abs($sum)*EPS) {
> >                                
> $gamser=$sum*exp(-$x+$a*log($x)-($gln));
> >                                 return;
> >                         }
> >                 }
> >                 echo "a=$a too large, ITMAX =
> $itmax too small in routine GSER<br />";
> >                 return;
> >         }
> > }
> >
> >
> > function gcf( &$gammcf,$a,$x,&$gln)
> > {
> >         $gold=0.0;
> >         $fac=1.0;
> >         $b1=1.0;
> >         $b0=0.0;
> >         $a0=1.0;
> >
> >         $gln=gammln($a);
> >         $a1=$x;
> >         for ($n=1;$n<=ITMAX;$n++) {
> >                 $an=(double) $n;
> >                 $ana=$an-$a;
> >                 $a0=($a1+$a0*$ana)*$fac;
> >                 $b0=($b1+$b0*$ana)*$fac;
> >                 $anf=$an*$fac;
> >                 $a1=$x*$a0+$anf*$a1;
> >                 $b1=$x*$b0+$anf*$b1;
> >                 if ($a1) {
> >                         $fac=1.0/$a1;
> >                         $g=$b1*$fac;
> >                         if (abs(($g-$gold)/$g) <
> EPS) {
> >                                
> $gammcf=exp(-$x+$a*log($x)-($gln))*$g;
> >                                 return;
> >                         }
> >                         $gold=$g;
> >                 }
> >         }
> >         echo "a too large, ITMAX too small in
> routine GCF<br />";
> > }
> > function gammp($a,$x)
> > {
> >
> >         if ($x < 0.0 || $a <= 0.0) {
> >                 echo "Invalid arguments in
> routine GAMMP<br />";
> >                 return 0.;
> >         }
> >         if ($x < ($a+1.0)) {
> >                 gser($gamser,$a,$x,$gln);
> >                 return $gamser;
> >         } else {
> >                 gcf($gammcf,$a,$x,$gln);
> >                 return 1.0-$gammcf;
> >         }
> > }
> >
> > function gammq($a,$x)
> > {
> >
> >         if ($x < 0.0 || $a <= 0.0) echo
> "Invalid arguments in routine GAMMQ<br />";
> >         if ($x < ($a+1.0)) {
> >                 gser($gamser,$a,$x,$gln);
> >                 return 1.0-$gamser;
> >         } else {
> >                 gcf($gammcf,$a,$x,$gln);
> >                 return $gammcf;
> >         }
> > }
> > function erfc($x)
> > {
> >
> >         return $x < 0.0 ? 1.0+gammp(0.5,$x*$x) :
> gammq(0.5,$x*$x);
> > }
> > function erf($x)
> > {
> >
> >         return $x < 0.0 ? -gammp(0.5,$x*$x) :
> gammp(0.5,$x*$x);
> > }
> > function myerf($argin) {
> >        return .5*(1.+erf($argin/sqrt(2.0)));
> > }
> >
> > ?>
> >
> > <form action="new_black_scholes.php"
> method="post">
> >     <p>
> >         Black Scholes Option Price Calculator:<br
> />
> >             temp website under Redhat Fedora 9
> Linux:<br />
> >             the first 5 boxes require input(try 100.
> 100. .12 .1 365.):<br />
> >     </p>
> >     <p>
> >         StockPrice (required):<br />
> >         <input type="text"
> size="20" maxlength="40"
> name="StockPrice"
> >         value="<?php
> >     if (IsSet($StockPrice))
> >     {
> >         echo $StockPrice;
> >     }
> >     else
> >     {
> >         echo " ";
> >     }
> >     ?>" />
> >     </p>
> >     <p>
> >         ExercisePrice (required):<br />
> >         <input type="text"
> size="20" maxlength="40"
> name="ExercisePrice"
> >         value="<?php echo $ExercisePrice;
> ?>" />
> > </p>
> >     <p>
> >         Risk Free Rate of Interest(required):<br
> />
> >         <input type="text"
> size="20" maxlength="40"
> name="RiskFreeRateInterest"
> >         value="<?php echo
> $RiskFreeRateInterest; ?>" />
> >     </p>
> >     <p>
> >         Instantaneous Variance Rate of Stock's
> Return (required):<br />
> >         <input type="text"
> size="20" maxlength="40"
> name="InstantaneousVarianceRateStocksReturn"
> >         value="<?php echo
> $InstantaneousVarianceRateStocksReturn; ?>" />
> > </p>
> >     <p>
> >         Time to Expiration of the Option(days)
> (required):<br />
> >         <input type="text"
> size="20" maxlength="40"
> name="TimetoExpirationOption"
> >         value="<?php echo
> $TimetoExpirationOption; ?>" />
> > </p>
> >     <p>
> >         Values of the Call Option :<br />
> >         <input type="text"
> size="20" maxlength="40" 
> name="ValueCallOption"
> >             VALUE="<?php echo
> $ValueCallOption; ?>" />
> > </p>
> > </p>
> >     <p>
> >         Values of the Put option :<br />
> >         <input type="text"
> size="20" maxlength="40" 
> name="ValuePutOption"
> >             VALUE="<?php echo $ValuePutOption;
> ?>" />
> > </p>
> >     <p>
> >         Delta(calls):<br />
> >         <input type="text"
> size="20" maxlength="40" 
> name="DeltaCalls"
> >             VALUE="<?php echo $DeltaCalls;
> ?>" />
> > </p>
> >     <p>
> >         Delta(puts):<br />
> >         <input type="text"
> size="20" maxlength="40" 
> name="DeltaPuts"
> >             VALUE="<?php echo $DeltaPuts;
> ?>" />
> > </p>
> >     <button type="submit" name =
> "submit" value="Calculate!"
> >     style="color:maroon font:18pt Courier;
> font-weight:bold ">Calculate
> >     </button>
> >     <button type="submit" name =
> "reset" value="Demo!"
> >     style="color:red font:18pt Courier;
> font-weight:bold ">Demo
> >     </button>
> > </form>
> >
> >
> >
> >
> >
> >       
> >
> >
> >


      


--- End Message ---
--- Begin Message ---
    For future reference, Fred, please only include the relevant code,
not the entire script.

On Mon, Dec 8, 2008 at 11:46 AM, Fred Silsbee <[EMAIL PROTECTED]> wrote:
[snip!]
>
> Under windows, the first page has an error <br /><b>Notice</b>:  Undefined 
> variable: ExercisePrice in <b>C:\Inetpub\wwwroot\new_black_scholes.php</b> on 
> line <b>198</b><br />

    This is just a matter of the INI settings error_reporting and/or
error_display being different.  It's not an OS thing at all.  You can
change php.ini on the offending system to this:

    error_reporting = E_ALL | ~E_NOTICE
    ; Note that the | is the pipe character.

    Preferably, though, the variable on line 198 should be defined.
It doesn't absolutely *NEED* to be, but good coding standards beg that
you do.

[snip!]
>        <input type="text" size="20" maxlength="40" name="ExercisePrice"
>        value="<?php echo $ExercisePrice; ?>" />
[snip!]

    There's your problem.  $ExercisePrice is called (within the <?php
?> tags), but was never defined before this.

-- 
</Daniel P. Brown>
http://www.parasane.net/
[EMAIL PROTECTED] || [EMAIL PROTECTED]
50% Off Hosting! http://www.pilotpig.net/specials.php

--- End Message ---
--- Begin Message ---
if you read my original post you'd see that I already know this!

I even inserted code to fix the problem. The problem is that the

values of the variable THE FIRST TIME are undefined as shown by the code I 

inserted.

I fixed the problem for one of the variables to make sure I perceived the 

problem correctly not being a html guru!

The question is again "Is there a better way?"




--- On Mon, 12/8/08, Daniel Brown <[EMAIL PROTECTED]> wrote:

> From: Daniel Brown <[EMAIL PROTECTED]>
> Subject: Re: [PHP-WIN] there must be better way to handle "Null" undefined 
> variables
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Date: Monday, December 8, 2008, 6:06 PM
> For future reference, Fred, please only include the relevant
> code,
> not the entire script.
> 
> On Mon, Dec 8, 2008 at 11:46 AM, Fred Silsbee
> <[EMAIL PROTECTED]> wrote:
> [snip!]
> >
> > Under windows, the first page has an error <br
> /><b>Notice</b>:  Undefined variable:
> ExercisePrice in
> <b>C:\Inetpub\wwwroot\new_black_scholes.php</b>
> on line <b>198</b><br />
> 
>     This is just a matter of the INI settings
> error_reporting and/or
> error_display being different.  It's not an OS thing at
> all.  You can
> change php.ini on the offending system to this:
> 
>     error_reporting = E_ALL | ~E_NOTICE
>     ; Note that the | is the pipe character.
> 
>     Preferably, though, the variable on line 198 should be
> defined.
> It doesn't absolutely *NEED* to be, but good coding
> standards beg that
> you do.
> 
> [snip!]
> >        <input type="text"
> size="20" maxlength="40"
> name="ExercisePrice"
> >        value="<?php echo $ExercisePrice;
> ?>" />
> [snip!]
> 
>     There's your problem.  $ExercisePrice is called
> (within the <?php
> ?> tags), but was never defined before this.
> 
> -- 
> </Daniel P. Brown>
> http://www.parasane.net/
> [EMAIL PROTECTED] || [EMAIL PROTECTED]
> 50% Off Hosting! http://www.pilotpig.net/specials.php


      


--- End Message ---
--- Begin Message ---
On Mon, Dec 8, 2008 at 1:24 PM, Fred Silsbee <[EMAIL PROTECTED]> wrote:
> if you read my original post you'd see that I already know this!

    Fred, I read your original post (the whole thing, which - if you
read the rules of these mailing lists, you'd see - you sent wrong, as
usual).

> The question is again "Is there a better way?"

    The BETTER way is doing it the RIGHT way, and not being so
abrasive with every single post you make to the mailing lists.  If you
already know the problem and how to fix it, then what's the issue
here?  Fix it.

-- 
</Daniel P. Brown>
http://www.parasane.net/
[EMAIL PROTECTED] || [EMAIL PROTECTED]
50% Off Hosting! http://www.pilotpig.net/specials.php

--- End Message ---
--- Begin Message ---
On Mon, 2008-12-08 at 10:24 -0800, Fred Silsbee wrote:
> if you read my original post you'd see that I already know this!
> 
> I even inserted code to fix the problem. The problem is that the
> 
> values of the variable THE FIRST TIME are undefined as shown by the code I 
> 
> inserted.
> 
> I fixed the problem for one of the variables to make sure I perceived the 
> 
> problem correctly not being a html guru!
> 
> The question is again "Is there a better way?"
> 
> 

If I write code that may be on a server I do not or can not control the
php.ini settings, I check for the existence of the variable before I use
it. This does increase the code size somewhat, but it makes the code
more reliable as well. If you are passing values through HTTP Post or
Get you will need something like this anyway to keep from typing the
super global variable name every time.

if (get_magic_quotes_gpc())
{
        // this should not be needed, but 
        //some sites still use get_magic_quotes_gpc
        if (array_key_exists('my_html_var', $_POST)
                $my_html_var = stripslashes($_POST['my_html_var']);
}
else
{
        if (array_key_exists('my_html_var', $_POST)
                $my_html_var = $_POST['my_html_var'];
}
if (!is_set($my_html_var))
{
        // set our variable to a known value
        $my_html_var = 'somevalue';
}

Cheers,
James




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






--- On Mon, 12/8/08, James Crow <[EMAIL PROTECTED]> wrote:

> From: James Crow <[EMAIL PROTECTED]>
> Subject: Re: [PHP-WIN] there must be better way to handle "Null" undefined 
> variables
> To: [EMAIL PROTECTED]
> Cc: "Daniel Brown" <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
> Date: Monday, December 8, 2008, 6:40 PM
> On Mon, 2008-12-08 at 10:24 -0800, Fred Silsbee wrote:
> > if you read my original post you'd see that I
> already know this!
> > 
> > I even inserted code to fix the problem. The problem
> is that the
> > 
> > values of the variable THE FIRST TIME are undefined as
> shown by the code I 
> > 
> > inserted.
> > 
> > I fixed the problem for one of the variables to make
> sure I perceived the 
> > 
> > problem correctly not being a html guru!
> > 
> > The question is again "Is there a better
> way?"
> > 
> > 
> 
> If I write code that may be on a server I do not or can not
> control the
> php.ini settings, I check for the existence of the variable
> before I use
> it. This does increase the code size somewhat, but it makes
> the code
> more reliable as well. If you are passing values through
> HTTP Post or
> Get you will need something like this anyway to keep from
> typing the
> super global variable name every time.
> 
> if (get_magic_quotes_gpc())
> {
>       // this should not be needed, but 
>       //some sites still use get_magic_quotes_gpc
>       if (array_key_exists('my_html_var', $_POST)
>               $my_html_var =
> stripslashes($_POST['my_html_var']);
> }
> else
> {
>       if (array_key_exists('my_html_var', $_POST)
>               $my_html_var = $_POST['my_html_var'];
> }
> if (!is_set($my_html_var))
> {
>       // set our variable to a known value
>       $my_html_var = 'somevalue';
> }
> 
> Cheers,
> James






your general concept is correct...do it the right way

I am not adhering to MY way but why isn't my fix OK?

One variable fixed...fixing the rest would cause code gloat.

I had a (flying) instrument instructor once who was famous for his teaching 
ability. 

If I made a mistake (and I did many times) he'd tell me why so I'd learn the 
concept. 

Thanks!

BTW is there anything you consider abrasive in my posts?

I am to the point to avoid post proliferation.

Here is only the pertinent code!

<form action="new_black_scholes.php" method="post">
    <p>
        Black Scholes Option Price Calculator:<br />
                temp website under Redhat Fedora 9 Linux:<br />
                the first 5 boxes require input(try 100. 100. .12 .1 365.):<br 
/>
    </p>
    <p>
        StockPrice (required):<br />
        <input type="text" size="20" maxlength="40" name="StockPrice"
                value="<?php 
        if (IsSet($StockPrice)) 
        {
                echo $StockPrice; 
        }
        else 
        {
                echo " ";
        }
        ?>" />
    </p>
    <p>
        ExercisePrice (required):<br />
        <input type="text" size="20" maxlength="40" name="ExercisePrice"
                value="<?php echo $ExercisePrice; ?>" />
</p>


      


--- End Message ---
--- Begin Message ---
> your general concept is correct...do it the right way
> 
> I am not adhering to MY way but why isn't my fix OK?
> 
> One variable fixed...fixing the rest would cause code gloat.

I think you mean Bloat.  Code doesn't take satisfaction from ruining
your day, it just feels like it does.

> I had a (flying) instrument instructor once who was famous for his teaching 
> ability. 
> 
> If I made a mistake (and I did many times) he'd tell me why so I'd learn the 
> concept. 
> 
> Thanks!
> 
> BTW is there anything you consider abrasive in my posts?
> 
> I am to the point to avoid post proliferation.
> 
> Here is only the pertinent code!
> 
> <form action="new_black_scholes.php" method="post">
>     <p>
>         Black Scholes Option Price Calculator:<br />
>               temp website under Redhat Fedora 9 Linux:<br />
>               the first 5 boxes require input(try 100. 100. .12 .1 365.):<br 
> />
>     </p>
>     <p>
>         StockPrice (required):<br />
>         <input type="text" size="20" maxlength="40" name="StockPrice"
>               value="<?php 
>       if (IsSet($StockPrice)) 
>       {
>               echo $StockPrice; 
>       }
>       else 
>       {
>               echo " ";
>       }
>       ?>" />
>     </p>
>     <p>
>         ExercisePrice (required):<br />
>         <input type="text" size="20" maxlength="40" name="ExercisePrice"
>               value="<?php echo $ExercisePrice; ?>" />
> </p>

Your problem, as you have half realised, is the variables are not
initialised.  The simple answer is to make sure they are initialised.
Put something like this as the FIRST line of your script:

$StockPrice = $ExercisePrice = 0;

Include all of the numeric variables into this line. You can replace the
'0' with an empty string if you prefer.
Your conditional check for the 'Reset' and 'Submit' will set those
variables that it needs to, and the remainder will still have default
values.
 This will save you bloating the code with the 'IsSet' checking.

--
Niel Archer



--- End Message ---
--- Begin Message ---
Daniel wrote:
I am creating a new website that uses ImageFlow (http://finnrudolph.de/ImageFlow/Installation)

I have created a test page for use with the new ImageFlow.js

When I load the webpage, I get the correct page except the pictures. This leads me to think that the pictures aren't being rendered by the extension php_gd2.dll

Any I on the right track here? Is there where I should be asking the question?

Are you try this at localhost?
Are you try by using basic script that create simple images?
I think You are in the right track?!

u said about create a test page. How about share to us you page?
i suggest put in zip.. since i know the page/script can't be only 1 file

--- End Message ---

Reply via email to