Why PHP Script Is Not Workig in a Web Browser

Why PHP script is not workig in a web browser?

Wikipedia is always a great resource of information. I suggest:

Server-side scripting

vs

Client-side scripting


And Wikipedia also has pictures:

Sample Image

PHP code is not being executed, but the code shows in the browser source code

Sounds like there is something wrong with your configuration, here are a few things you can check:

  1. Make sure that PHP is installed and running correctly. This may sound silly, but you never know. An easy way to check is to run php -v from a command line and see if returns version information or any errors.

  2. Make sure that the PHP module is listed and uncommented inside of your Apache's httpd.conf This should be something like LoadModule php5_module "c:/php/php5apache2_2.dll" in the file. Search for LoadModule php, and make sure that there is no comment (;) in front of it.

  3. Make sure that Apache's httpd.conf file has the PHP MIME type in it. This should be something like AddType application/x-httpd-php .php. This tells Apache to run .php files as PHP. Search for AddType, and then make sure there is an entry for PHP, and that it is uncommented.

  4. Make sure your file has the .php extension on it, or whichever extension specified in the MIME definition in point #3, otherwise it will not be executed as PHP.

  5. Make sure you are not using short tags in the PHP file (<?), these are not enabled on all servers by default and their use is discouraged. Use <?php instead (or enable short tags in your php.ini with short_open_tag=On if you have code that relies on them).

  6. Make sure you are accessing your file over your webserver using an URL like http://localhost/file.php not via local file access file://localhost/www/file.php

And lastly check the PHP manual for further setup tips.

Php script is working properly but in the browser its not working

After some changes of permissions it worked:

chown -R www-data:www-data /var/www
chmod go-rwx /var/www
chmod go+x /var/www
chgrp -R www-data /var/www
chmod -R go-rwx /var/www
chmod -R g+rx /var/www
chmod -R g+rwx /var/www

Why is my PHP Code not Working , HTML website?

When you load the pages into your browser via file://, the PHP script will not be executed by the PHP interpreter.

You need a webserver running on your machine - e.g. Apache or IIS - which is configured to serve PHP files, and then you need to go to the page in your browser like http://localhost/contact.html so that when you submit the form, it would end up posting to http://localhost/column-form-handler.php (instead of file://column-form-handler.php or whatever).

Doing this means that the webserver will pass requests for .php files to the PHP interpreter, which will execute them, and pass the result of executing the code (as opposed to just the raw source code) back to the webserver which then returns it to the client (i.e. browser).

PHP script not running on browser

Put your scripts into /XAMPP/htdocs and then point your browser to: http://localhost/your_script.php

php script not working in Internet explorer and Firefox

(Just a debug idea) Try to change your input image to a hidden element like this :

<form action="python.php" method="post">
<!-- I don't remove this, to keep the image shown-->
<input name="addimg" src="images/add.png" type="image" value="3">

<input type='hidden' name='add' value='3' />
</form>

Does it works now?



Related Topics



Leave a reply



Submit