php-windows Digest 14 Aug 2003 12:48:59 -0000 Issue 1870
Topics (messages 21145 through 21151):
Re: How to preserve value , this question so difficult
21145 by: J.Veenhuijsen
Re: PHP My first function (help)!!!!
21146 by: Svensson, B.A.T. (HKG)
21147 by: Svensson, B.A.T. (HKG)
21148 by: Svensson, B.A.T. (HKG)
21149 by: David
21150 by: David
Problem with installing Php
21151 by: Almaz Ibragimov
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 ---
It is not a browser warning but a warning from the php interpretor!
The out put you see is generated by php.exe
Jochem
Thomas Edward Lawrence wrote:
Excellent , thank so much , and I also want to ask why my browser warns this
when I run page1.php at first time , whether I must make something in
php.ini , I use IE6 , win2k , thank for your anwsering .
Warning: Cannot send session cookie - headers already sent by (output
started at C:\PHP\baitap\session.php:11) in C:\PHP\baitap\session.php on
line 12
Warning: Cannot send session cache limiter - headers already sent (output
started at C:\PHP\baitap\session.php:11) in C:\PHP\baitap\session.php on
line 12
Notice: Undefined index: value in C:\PHP\baitap\session.php on line 13
1
Next page
"J.Veenhuijsen" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Try this for page 2:
<?php
session_start() ;
?>
<form method="POST" action="page1.php">
<?php
$value++ ;
echo $value ;
?>
<br>
<input type="submit" value="Submit" name="B1">
</form>
In your version session_start() should be sent before any other output
is sent.
Jochem
Thomas Edward Lawrence wrote:
this is page1.php
<?
session_start() ;
echo $value ;
if (!session_is_registered("value") )
{
session_register("value") ;
$value = 1 ;
}
echo $value ;
?>
<br>
<a href="page2.php">Next page</a>
this is page2.php
<form method="POST" action="page1.php">
<?
session_start() ;
$value++ ;
echo $value ;
?>
<br>
<input type="submit" value="Submit" name="B1">
</form>
when I come back to page1.php from page2.php , this is result :
page1.php ( run at first time)
Warning: Cannot send session cookie - headers already sent by (output
started at C:\PHP\page1.php:9) in C:\PHP\\page1.php on line 10
Warning: Cannot send session cache limiter - headers already sent
(output started at C:\PHP\page1.php:9) in C:\PHP\page1.php on line 10
Notice: Undefined variable: value in C:\PHP\page1.php on line 11
1 (value of $value)
Next page
page2.php
Warning: Cannot send session cache limiter - headers already sent
(output started at C:\PHP\page2.php :10) in C:\PHP\page2.php on line 11
2 (value of $value)
page1.php ( when come back from page2.php)
Warning: Cannot send session cookie - headers already sent by (output
started at C:\PHP\page1.php :9) in C:\PHP\page1.php on line 10
Warning: Cannot send session cache limiter - headers already sent
(output started at C:\PHP\page1.php:9) in C:\PHP\page1.php on line 10
Notice: Undefined variable: value in C:\PHP\page1.php on line 11
(browser not understanding $value)
1 (value of $value still 1)
Next page
Nothing changes , value of $value still is 1 , this question is so
difficult , I also want to ask why my browser warns , how I must config in
php.ini , I use IE6 , win2k , thank for reading .
--- End Message ---
--- Begin Message ---
> $TotalString = "$total";
> function Price($total)
> {
> [...]
> return "$Price";
> }
>
> echo "$Price";
It is not clear what your problem is, or what you tries to achive.
--- End Message ---
--- Begin Message ---
> Guys I need help!
>
> I think I am on the right track with my logic but my code fails.
> Can someone help? (my coding is weak no formal training).
I do not want to be rude, but you should try to pick up
basic programming principles, and then you wants to get
yourself familiar with the syntax of php. You can find
good information about this if you read the page found at:
http://www.php.net/manual/en/control-structures.php
Otherwise you function is so full of syntactic and semantic faults
it is not really possible to understand what it is you want to do.
--- End Message ---
--- Begin Message ---
> You cannot use comparision operaters (<=, >=, >) with strings.
> When you put quotes around your variable it defines it to
> php as a string, which translated means that it's words, not
> numbers. So you could say
> if ("$total" == "lowprice") {
> code code code
> }
>
> but not say ("$total" >= 25) {
> code code code
> }
In fact you can say that, since php is type less and does implicit
casting, it will evaluate it as integer comparisment in both cases.
> Also, you have defined your intergers as strings.
Which is not a good practice, but it will work,
since php will keep track on the casting.
> You're much better off with comparision operators using only
> intergers rather than comparing two strings that should be intergers.
I agree with you.
--- End Message ---
--- Begin Message ---
Dear Frank
You probably need to get a book, but here are two examples, one using if statements,
and the other using the switch/case statement.
<html>
<head>
<title>Untitled</title>
</head>
<body>
<?php
//initialise the $total
$total = 51;
//$TotalString = the return of the function. Pass $total to the function
$TotalString = Price($total);
//Display the total
echo $TotalString;
function Price($ftotal)
{
//add 5 to the function
if ($ftotal <= 30)
{
$ftotal *= 3200;
}
else if($ftotal <= 50)
{
$ftotal *= 4500;
}
else
{
$ftotal *= 6500;
}
//return the value to $TotalString
return $ftotal;
}
?>
</body>
</html>
<html>
<head>
<title>Untitled</title>
</head>
<body>
<?php
//initialise the $total
$total = 51;
//$TotalString = the return of the function. Pass $total to the function
$TotalString = Price($total);
//Display the total
echo $TotalString;
function Price($ftotal)
{
switch($ftotal)
{
case $ftotal <= 30:
$ftotal *= 3200;
break;
case $ftotal <= 50:
$ftotal *= 4500;
break;
default:
$ftotal *= 6500;
}
//return the value to $TotalString
return $ftotal;
}
?>
</body>
</html>
--
Kind Regards
David
Anagram Systems
http://www.anagram-sys.co.uk/
http://www.web-planets.com/davec/techsitedb/
"Frank Tudor" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> Guys I need help!
>
> I think I am on the right track with my logic but my code fails.
> Can someone help? (my coding is weak no formal training).
>
> Thanks,
> Frank
>
>
> $TotalString = "$total";
> function Price($total)
> {
> if "$total" <= "24" then "$total" * "3200"
> else
> if "$total" >= "25" and "$total" <= "49" then "$total" *
> "3000"
> else
> if "$total" >= "50" and "$total" <= "99" then "$total" *
> "2900"
> else
> if "$total" >= "100" then "$total" * "2700"
> return "$Price";
> }
> echo "$Price";
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
--- End Message ---
--- Begin Message ---
Sorry outlook screwed my code a bit
Dear Frank
You probably need to get a book, but here are two examples, one using if statements,
and the other using the switch/case statement.
<html>
<head>
<title>Untitled</title>
</head>
<body>
<?php
//initialise the $total
$total = 51;
//$TotalString = the return of the function. Pass $total to the function
$TotalString = Price($total);
//Display the total
echo $TotalString;
function Price($ftotal)
{
//add 5 to the function
if ($ftotal <= 30)
{
$ftotal *= 3200;
}
else if($ftotal <= 50)
{
$ftotal *= 4500;
}
else
{
$ftotal *= 6500;
}
//return the value to $TotalString
return $ftotal;
}
?>
</body>
</html>
<html>
<head>
<title>Untitled</title>
</head>
<body>
<?php
//initialise the $total
$total = 51;
//$TotalString = the return of the function. Pass $total to the function
$TotalString = Price($total);
//Display the total
echo $TotalString;
function Price($ftotal)
{
switch($ftotal)
{
case $ftotal <= 30:
$ftotal *= 3200;
break;
case $ftotal <= 50:
$ftotal *= 4500;
break;
default:
$ftotal *= 6500;
}
//return the value to $TotalString
return $ftotal;
}
?>
</body>
</html>
--
Kind Regards
David
Anagram Systems
http://www.anagram-sys.co.uk/
http://www.web-planets.com/davec/techsitedb/
"Frank Tudor" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> Guys I need help!
>
> I think I am on the right track with my logic but my code fails.
> Can someone help? (my coding is weak no formal training).
>
> Thanks,
> Frank
>
>
> $TotalString = "$total";
> function Price($total)
> {
> if "$total" <= "24" then "$total" * "3200"
> else
> if "$total" >= "25" and "$total" <= "49" then "$total" *
> "3000"
> else
> if "$total" >= "50" and "$total" <= "99" then "$total" *
> "2900"
> else
> if "$total" >= "100" then "$total" * "2700"
> return "$Price";
> }
> echo "$Price";
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
--- End Message ---
--- Begin Message ---
I installed php 4.3.2 version on Windows 2000 Server Family. HTTP Server is:
IIS 5.0.
But php is not working. I installed like in manuals. Then I add phpmyadmin.
And PhpMyAdmin is working, but php-nuke is not working? What can be the
problem?
--- End Message ---