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?

Link to comment
Share on other sites

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).

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.