This is a discussion on Php newbie ; $connection and <?=$_SERVER['PHP_SELF']?> within the alt.comp.lang.php forums, part of the PHP Programming Forums category; First, Happy New Year 2007 in your office with MS Office! My question is not MS related. It's about ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
First, Happy New Year 2007 in your office with MS Office!
My question is not MS related. It's about Php. I have started learning it although I am not a programer. I have installed Apache and MySql on my computer and set up Php to work along. Then I also have PhpMyAdmin working from my Usb kye to avoid any conflict with the Apache installation on my hard drive. As done with my curriculum, I would like to know why the following script doesnt work when I run it directly from the Apache Server (I get : "Forbidden You don't have permission to access /< on this server." : ===O=== <html> <head> </head> <body> <?php $_POST = ''; if (!$_POST['submit']) { ?> <form action="<?=$_SERVER['PHP_SELF']?>" method="post"> Enter a number : <input name='numb' size="2"> <input type="submit" name="submit" value="Valider"> </form> <?php } else { $nombre = $_POST['numb']; if ($numb < 0) {echo 'your number is -'; } elseif ($numb = 0) {echo 'you have entered 0'; } else {echo 'your number is +'; } } ?> </body> </html> ===O=== When I run the same script on PhpMyAdmin, I have this message : Notice: Uninitialized string offset: 0 in g:\easyphp1-8\www\site2practise\ex15h.php on line 13 line 13 is about this: if (!$_POST['submit']). and if I delete the entire "if" structure, still running the script on PhpMyAdmin, I get: "Notice: Undefined index: nombre in g:\easyphp1-8\www\site2practise\ex15.php on line 25" Line 25 is about this: $nombre = $_POST['nombre']; I don't think the last 2 errors are linked with the first one. The last 2 could be about the syntax and/or Php version I am running. Now I think I know the answer on how to solve the first error about Forbidden access It's because I have set a password when I installed Apache. And the issue is not the same when I run the script from PhpMyAdmin, because there I have no password setup. So the issue is about the syntax. How can the script above run on a Php engine that was setup with a password with little change? for instance -> $connection = mysql_connect($host, $user, $pass) or die ('impossible de se connecter!'); ??? Thanks, Pascal |
|
|||
|
psnospam@googlemail.com schrieb:
> First, Happy New Year 2007 in your office with MS Office! > > My question is not MS related. It's about Php. I have started learning > it although I am not a programer. > > I have installed Apache and MySql on my computer and set up Php to work > along. Then I also have PhpMyAdmin working from my Usb kye to avoid any > conflict with the Apache installation on my hard drive. > > As done with my curriculum, I would like to know why the following > script doesnt work when I run it directly from the Apache Server (I get > : > > "Forbidden > > You don't have permission to access /< on this server." : Your webserver setup is not o. > > ===O=== > > <html> > <head> > </head> > > <body> > > <?php > > $_POST = ''; > > if (!$_POST['submit']) > > { > > ?> > > <form action="<?=$_SERVER['PHP_SELF']?>" method="post"> > > Enter a number : <input name='numb' size="2"> > > <input type="submit" name="submit" value="Valider"> > > </form> > > <?php > > } > > else > > { > > $nombre = $_POST['numb']; > > if ($numb < 0) > > {echo 'your number is -'; > > } > > elseif ($numb = 0) > > {echo 'you have entered 0'; > > } > > else > > {echo 'your number is +'; > > } > } > > ?> > > </body> > > </html> > > ===O=== > > When I run the same script on PhpMyAdmin, I have this message : > > Notice: Uninitialized string offset: 0 in > g:\easyphp1-8\www\site2practise\ex15h.php on line 13 > > line 13 is about this: > > if (!$_POST['submit']). you didn't call this page from a form that has a form element submit, so you cannot evaluate $_POST['submit'], therefore you should check it this way: if(!isset($_POST['submit'])) > > and if I delete the entire "if" structure, still running the script on > PhpMyAdmin, I get: > > "Notice: Undefined index: nombre in > g:\easyphp1-8\www\site2practise\ex15.php on line 25" > > Line 25 is about this: > > $nombre = $_POST['nombre']; same here no nombre in POST data. > > I don't think the last 2 errors are linked with the first one. The last > 2 could be about the syntax and/or Php version I am running. > > Now I think I know the answer on how to solve the first error about > Forbidden access > > It's because I have set a password when I installed Apache. And the apache setup needs no password, if you have created an htpass file then you may need to adjust the webserver configuration. > issue is not the same when I run the script from PhpMyAdmin, because > there I have no password setup. So the issue is about the syntax. > > How can the script above run on a Php engine that was setup with a > password with little change? for instance > > -> $connection = mysql_connect($host, $user, $pass) or die ('impossible > de se connecter!'); > > ??? > > Thanks, > > Pascal > I think you should first get a basic php + Apache/IIS install. |
|
|||
|
In addition to Richard answer. If you just want Apache/MySQL/PHP to
work, not knowing how they fit together, I suggest LAMP (I think the site is called apachefriend or something like that - Just google it, and you'll find it). It is a package installation. You won't learn how to set up server properly tho. Hendri Kurniawan psnospam@googlemail.com wrote: > First, Happy New Year 2007 in your office with MS Office! > > My question is not MS related. It's about Php. I have started learning > it although I am not a programer. > > I have installed Apache and MySql on my computer and set up Php to work > along. Then I also have PhpMyAdmin working from my Usb kye to avoid any > conflict with the Apache installation on my hard drive. > > As done with my curriculum, I would like to know why the following > script doesnt work when I run it directly from the Apache Server (I get > : > > "Forbidden > > You don't have permission to access /< on this server." : > > ===O=== > > <html> > <head> > </head> > > <body> > > <?php > > $_POST = ''; > > if (!$_POST['submit']) > > { > > ?> > > <form action="<?=$_SERVER['PHP_SELF']?>" method="post"> > > Enter a number : <input name='numb' size="2"> > > <input type="submit" name="submit" value="Valider"> > > </form> > > <?php > > } > > else > > { > > $nombre = $_POST['numb']; > > if ($numb < 0) > > {echo 'your number is -'; > > } > > elseif ($numb = 0) > > {echo 'you have entered 0'; > > } > > else > > {echo 'your number is +'; > > } > } > > ?> > > </body> > > </html> > > ===O=== > > When I run the same script on PhpMyAdmin, I have this message : > > Notice: Uninitialized string offset: 0 in > g:\easyphp1-8\www\site2practise\ex15h.php on line 13 > > line 13 is about this: > > if (!$_POST['submit']). > > and if I delete the entire "if" structure, still running the script on > PhpMyAdmin, I get: > > "Notice: Undefined index: nombre in > g:\easyphp1-8\www\site2practise\ex15.php on line 25" > > Line 25 is about this: > > $nombre = $_POST['nombre']; > > I don't think the last 2 errors are linked with the first one. The last > 2 could be about the syntax and/or Php version I am running. > > Now I think I know the answer on how to solve the first error about > Forbidden access > > It's because I have set a password when I installed Apache. And the > issue is not the same when I run the script from PhpMyAdmin, because > there I have no password setup. So the issue is about the syntax. > > How can the script above run on a Php engine that was setup with a > password with little change? for instance > > -> $connection = mysql_connect($host, $user, $pass) or die ('impossible > de se connecter!'); > > ??? > > Thanks, > > Pascal > |
|
|||
|
Hendri Kurniawan wrote:
> In addition to Richard answer. If you just want Apache/MySQL/PHP to > work, not knowing how they > fit together, I suggest LAMP (I think the site is called apachefriend > or something like that - Just google it, I think you mean XAMPP? -- Rik Wasmus |
|
|||
|
Yup I was just going to amend that.
:) Hendri Kurniawan Rik wrote: > Hendri Kurniawan wrote: >> In addition to Richard answer. If you just want Apache/MySQL/PHP to >> work, not knowing how they >> fit together, I suggest LAMP (I think the site is called apachefriend >> or something like that - Just google it, > > I think you mean XAMPP? > |
|
|||
|
I use XAMPP for off-server site testing. Its a great tool for either setting up
your own minimal-hassle web server or as a script testing device. Hendri Kurniawan wrote: > Yup I was just going to amend that. > :) > > Hendri Kurniawan > > Rik wrote: >> Hendri Kurniawan wrote: >>> In addition to Richard answer. If you just want Apache/MySQL/PHP to >>> work, not knowing how they >>> fit together, I suggest LAMP (I think the site is called apachefriend >>> or something like that - Just google it, >> >> I think you mean XAMPP? >> |