473,405 Members | 2,176 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Php... 01 greater than 1 ???

First, sorry for telling you so little with this issue and leaving it
for so long without much care from me...

Below you can find the script that made feel confused (I am an early
Php beginner but I have to stop as for professional needs I need to
concentrate my free time on learning VBA...) :

Test it with 01 as I can't test it on my current configuration(see
below why).

===========start==========
<html>
<head>
</head>

<body>

<?php

//lancer recherche $_POST['submit'] dans fichier aide PHP

if (!$_POST['submit'])

{

?>

<form action="<?=$_SERVER['PHP_SELF']?>" method="post">

Saisissez un nombre : <input name="nombre" size="2">

<input type="submit" name="submit" value="Valider">

</form>

<?php

}

else

{

$nombre = $_POST['nombre'];

if ($nombre < 0)

{echo 'Vous avez saissi un nombre -';
}

elseif ($nombre 0)

{echo 'Vous avez saissi +';
}

else

{echo 'Vous avez saissi un nombre neutre';
}

}

?>

</body>
</html>

===========end==========
As I changed computer, I had to reinstall php, apache and I wanted to
test this script again but I had this message:

You don't have permission to access /arch/< on this server.

The other script I run all are working (with forms...) under XP.

It's no big issue for me right now as it's confusing learning 2
languages at the same time... so I am concentrating on vba and leaving
Php for later...

May 28 '07 #1
3 1609
On 28 Mai, 22:43, wbrowse <wbro...@gmail.comwrote:
First, sorry for telling you so little with this issue and leaving it
for so long without much care from me...

Below you can find the script that made feel confused (I am an early
Php beginner but I have to stop as for professional needs I need to
concentrate my free time on learning VBA...) :

Test it with 01 as I can't test it on my current configuration(see
below why).

===========start==========

<html>
<head>
</head>

<body>

<?php

//lancer recherche $_POST['submit'] dans fichier aide PHP

if (!$_POST['submit'])

{

?>

<form action="<?=$_SERVER['PHP_SELF']?>" method="post">

Saisissez un nombre : <input name="nombre" size="2">

<input type="submit" name="submit" value="Valider">

</form>

<?php

}

else

{

$nombre = $_POST['nombre'];

if ($nombre < 0)

{echo 'Vous avez saissi un nombre -';

}

elseif ($nombre 0)

{echo 'Vous avez saissi +';

}

else

{echo 'Vous avez saissi un nombre neutre';

}
}

?>

</body>

</html>

===========end==========

As I changed computer, I had to reinstall php, apache and I wanted to
test this script again but I had this message:

You don't have permission to access /arch/< on this server.

The other script I run all are working (with forms...) under XP.

It's no big issue for me right now as it's confusing learning 2
languages at the same time... so I am concentrating on vba and leaving
Php for later...
Maybe you've installed a newer PHP-Version or you've forgott to
configure PHP. I see the usage of short tags inside your script (<form
action="<?=$_SERVER['PHP_SELF']?>" method="post">).

If handling of short tags are deactivated (this is the default
setting), PHP will not parse the code <?=$_SERVER['PHP_SELF']?>.
Instead of that, the HTML output will contain it as string.

You can change this behaviour by setting "short_open_tag = Off" in the
php.ini file, which should be present either normally in C:\WINDOWS\
or inside the PHP installation directory.

But the better alternative is not to use short tags syntax and to
change your script as follows:
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
purcaholic

May 28 '07 #2
Thanks,

For the first issue, I came to understand from a similar post I made
earlier that the reason why 01 is greater than 1 is because of :

$nombre = $_POST['nombre']

the memory address is the one that is being tested and 01 is greater
than 1 because 01 is 2 characters long... is it the explanation?

About the second issue, I remember having some php or apache
configuration issues as I did some installation on different computer
running windows xp home or pro.... and for some the same configuration
would work and for others it wouldn't so at some point I had to
install the xamp all in one software that make things go smoothly.

For now, I have set the short tag "off" to "on" in php.ini and I have
also changed the php script to echo $_SERVER but with the first change
(and with no change in code), it still gives me a forbidden message,
and for the second change (leaving php.ini "on" or "off"), it does
nothing when I click submit like, I get the same blank input box as I
got before entering a number...

It might be something either very little or something a very early
irregular php learner like me can't get and so obvious to any one else
php litterate....

One last thing, is it okay for someone to learn vba thinking that
after getting vba skills (after a year or two giving it about 4 hours
a week), it will be convenient to go on learning php? However so far
with Vba, it looks closer to java than php. I would like to know an
open-source language and apart vba, learning those language would just
be a hobby. But there are so many language and the web technologies
are moving quite fast ...see ajax... so someone without any IT
academic like me can feel quite confused.

Thanks again
May 29 '07 #3
wbrowse wrote:
Thanks,

For the first issue, I came to understand from a similar post I made
earlier that the reason why 01 is greater than 1 is because of :

$nombre = $_POST['nombre']

the memory address is the one that is being tested and 01 is greater
than 1 because 01 is 2 characters long... is it the explanation?
well, php dont support type definitions. That means variables will get
evaluated based on the operation. I had similar problems with a switch
statement comparing a value with leading zero with a number. For me it
looked like the value with leading zero "01" got interpreted as string
and compared with the number 1 the result is false.

That should help you out:
$nombre = (int) $_POST['nombre'];

More about this topic:
http://php.net/manual/en/language.ty...e-juggling.php
May 29 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Martin | last post by:
I am trying to write code that selects a random number in the range 0 to n, where n can be substantially greater than the RAND_MAX on my system which is 32767. I am using VC++ 2003 FWIW. As you...
3
by: Massimiliano Alberti | last post by:
Can someone check this? If it's OK, you can use however you want... :-) It should search for an element in an array and, if it can't find it, return the next element. key is what you are...
2
by: John Mark Howell | last post by:
BlankDoes anyone know how to overload the greater than (>) operator? I know that it is probably not in accordance to the framework design patterns, but it would make my code much cleaner. -- ...
7
by: BobRoyAce | last post by:
Let's say I have a text box on a page in which a user is to enter a monetary amount and that I want to ensure that the user enters a value greater than or equal to a certain value that will be...
0
by: Michael Mallete | last post by:
good day everyone! i am using postgresql-8.0beta2-dev3 windows port, with postgis-0.9 add-on. anyway, while trying to insert a table using shp2pgsql, i get this error: psql:temp.sql:38:...
2
by: James | last post by:
i m looking for suggestions in this news groups what is the best way to delete files greater than x days. scenario / conditions a) d:\dir\queue\*.* files to be deleted. b) no-touch solutions ...
2
by: Stevie | last post by:
Hello I'm trying to work out the regular expression for carrying out a simple 'greater than' comparison. I have a directory with files such as asd345.log, asd346.log, asd347.log and so on.
13
by: HockeyFan | last post by:
I'm not sure how to exactly ask this, but expect that it's a Javascript solution. However, I'll ask the question and maybe someone can point me to some existing code that will do what I need. I...
4
by: minsumoosane | last post by:
Hello, Can anyone help me write a php program that have two numbers as input and then choose the greater number of the two.For example, 2 and 7 and choosing 7 as the greater number Thank you so...
1
by: ciojr | last post by:
how do i write a sql (ORACLE) statement for where the first word in the name field is greater than 17 chars? if i do this SELECT businessname FROM tablename WHERE LEN(businessname) 17; it...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.