PHP script doesn't work when using Wamp server

I have installed wamp server on my windows 7 machine. It shows all services are running. It runs Apache, runs PHP as well as MySQL. I have the latest Chrome browser installed.

I'm trying to run the following code on a website, but I'm just getting a basic HTML page without a PHP script.

Here is my code:

<html>

<head>
    <title>Php Tutorial</title>
</head>

<body>

    <h3>Php tutorials</h3>
    <hr>

    <a href="?page=home">Home</a>
    <a href="?page=tutorial">Tutorials</a>
    <a href="?page=about">About</a>
    <a href="?page=contact">Contact</a>
    <hr>

    <?php
    error_reporting(E_ALL);
    ini_set('display_errors', 1);
    echo "testing";
    print_r($_REQUEST);

    ?>

</body>

      

I looked around and they suggested that I install PHP, Apache and MySQL. I have all three working with phpMyAdmin using a wamp server. What am I missing?

I fixed the testing issues by counting as non-string and added a bug report, but I still can't see the testing showing up on the webpage.

+3


source to share


2 answers


As per your original post - what @JayBlanchard said to use in regards to using bug reporting would trigger an ongoing Undefined testing notification.

Therefore, you need to wrap the word "testing" in quotes:

echo "testing";

      

Add an error report to the beginning of the file to help you find errors.

<?php 
error_reporting(E_ALL);
ini_set('display_errors', 1);

// rest of your code

      

Sidenote: Bug reports should only be done at the staging stage and should never be done.


Refer to the line guide:

and by constants:



If you want to use a constant, all you have to do is define it:

define('testing', 'this part gets printed, not the name of the constant');

      

The convention is to use uppercase words for the constant name, so instead of "testing" it will be "TESTING".

define('testing', 'this part gets printed, not the name of the constant');

      

Then you can use a constant:

echo TESTING; // no quotes, echos 'this part gets printed, not the name of the constant'

      


Edit:

as per your edit: is your file's extension valid .php

and how do you refer to it? how http://localhost/file.php

or how file:///file.php

?

OP: it looks like file: /// C: / xy

  • It should be http://localhost/file.php

+2


source


This should read:

echo "testing";

      



you are missing quotes.

+1


source







All Articles