Jump to content

PHP scripts not running, but installation appears to have succeeded


Recommended Posts

I am -running Vista Ultimate 64

Apache 2.2

PHP-5.2.9-1

MySQL 5.1

 

I installed and configured everything, seemingly correctly. I call phpinfo() and it shows mysql and mysqli sections. C:\php is added to path. Its reading the correct php.ini file. Everything in this indicates that php is working well. However, when I try to run other php scripts, for example:

 

<?php  mysql_connect('localhost','root','password') or die('Couldn\'t connect to server.'); ?>

 

I get a blank screen. Nothing appears when I "view source"

 

Secondly, http://localhost does not work, so I am accessing through http://127.0.0.1

nection)

 

I also tested this out which got me another blank screen:

 

<html>

<head></head>

<body>

<?php

/* if the "submit" variable does not exist, the form has not been submitted - display initial page */

if (!isset($_POST['submit'])) {

?>

 

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

    Enter your age: <input name="age" size="2">

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

    </form>

 

<?php

    }

else {

/* if the "submit" variable exists, the form has been submitted - look for and process form data */

    // display result

    $age = $_POST['age'];

    if ($age >= 21) {

        echo 'Come on in, we have alcohol and music awaiting you!';

        }

    else {

        echo 'You're too young for this club, come back when you're a little older';

    }

}

?>

</body>

</html>

 

any help would be welcomed

 

thanks

Link to comment
Share on other sites

Make sure you're saving your PHP code within .php files.

 

As for this issue

Secondly, http://localhost does not work, so I am accessing through http://127.0.0.1

You may need to add the following line

127.0.0.1       localhost

to your hosts file, which is located in C:\Windows\System32\drivers\etc

 

NOTE: To edit the hosts file in Vista you'll need to run your editor with Administrator privileges (right click your text editor icon and select run as administrator)

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.