Jump to content

[SOLVED] Accessing databases on localhost, URL changes to www.localhost.com instead.


DavidGS

Recommended Posts

So I am learning PHP and I was reading over how PHP can connect to databases, so I created a MySQL database and wrote a small program in PHP to see if it can access the database. Assuming my MySQL username was "user" password was "password" and I was accessing a database named "exampledb", the code would be:

 

DB::connect('mysql://user:password@localhost/exampledb');

 

BUT when I run the program in Firefox, instead of connecting to http://localhost/ it connects to http://www.localhost.com/ and I don't want that to happen. How can I fix this?

It still does it!

 

This is driving me nuts, even when I test to see if PEAR works it still redirects.

 

<?php
require 'DB.php';

if (class_exists('DB')) 
{
    print "ok";
} 
else 
{
    print "failed";
}
?>

 

This code should print "OK" if PEAR's installed, but all it does (in order) is:

 

1. Tries connecting to localhost

2. Says it's transferring data from localhost

3. Says it's connecting to www.localhost.com

4. Says it can't find the server on www.localhost.com

 

What is going on?!  ???

 

I have WAMP Server installed and I am accessing the file by typing in http://localhost/peartest.php (the file's in the directory and everything).

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.