Jump to content

localhost not working?


Recommended Posts

How do I know if localhost is working or not?

I think I might have this problem too by reading the posts here, I'm using XAMPP 1.7.3. I don't know what's supposed to happen or what isn't, but when i go to http://localhost it goes straight to the XAMPP interface.

 

Reason I'm wondering is because I've tried doing a login script from a tutorial (

) but I get "Couldn't connect" with it after putting in correct username and password, and I'm assuming it's localhost that's bugging cause I did everything like in the tutorial. Here's the script for the 2 php files:

 

<html>

	<form action='login.php' method='POST'>
			Username: <input type='text' name ='username'><br>
			Password: <input type='password' name ='password'><br>
			<input type='submit' value='Log in'>

	</form>
</html>>

 

<?php

$username = $_POST['username'];
$password = $_POST['password'];

if ($username&&$password)
{

$connect = mysql_connect("localhost","root","") or die("Couldn't connect");
mysql_select_db("logintest") or die("Couldn't find database");

$query = mysql_query("SELECT * FROM users WHERE username='$username'");

$numrows = mysql_num_rows ($query);

echo $numrows;

}
else
	die("Type in username and password");


?>

 

I'm a beginner at this, any help would be appreciated :)

Link to comment
Share on other sites

Ah so it created a new thread, ok now I know that :P

 

Sorry, I'm as much of a beginner as possible.

 

What I mean by not being able to connect I refer to this piece of string in the second script I posted:

 

$connect = mysql_connect("localhost","root","") or die("Couldn't connect");

Link to comment
Share on other sites

No, I actually split the post off of the old thread. People tend to ignore old threads that are dredged up.

 

While in development, change the MySQL connection code so it returns the actual error instead of a generic 'Couldn't connect" error message.

 

$connect = mysql_connect("localhost","root","") or die( mysql_error() );

Link to comment
Share on other sites

You don't have a password set up for you database server?

 

Appearantly not, I just pretty much installed it and started with the tutorial...

 

Well, I have a password for the actual website that I got from my webhotel one.com but not sure if that's the same thing...

 

Where is srv200.one.com coming from?

 

you're asking me? :P well I know one.com is the webhotel I'm using, but as for the srv200 part, no clue.

 

Link to comment
Share on other sites

Object not found!

 

The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

 

If you think this is a server error, please contact the webmaster.

Error 404

localhost

2011-01-22 20:09:30

Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1

Link to comment
Share on other sites

well phpMyAdmin that is... Still having problems connecting through my login script. I set up passwords for XAMPP, MySQL admin user root and PhpMyAdmin, but I'm still getting:

 

Access denied for user 'root'@'srv200.one.com' (using password: NO)

 

I restarted MySQL and cleared cache on my internet browers...

Link to comment
Share on other sites

You're not trying to connect to your local mysql server (the one that comes with XAMPP).

You're trying to connect to a remote one. (srv200.one.com)

If you want to use one.com's MySQL server, ask them what the password should be. And check that they allow you to access it from a remote address. (Lots only let you use it from their servers)

Link to comment
Share on other sites

  • 2 months later...

MY localhost not working.am checking my host file it contain

127.0.0.1      localhost

      ::1            localhost

 

127.0.0.1      example.oi

127.0.0.1      example.oi

 

these  lines.I also created virtual hosts for my projects.When am trying to run my localhost it automaticaly redirect to first virtual host.Anybody can help me.I changed my working directory from  c to another drive and  xampp installed also in that directory.All virtual hosts are working but localhost not working please help me

 

 

Thanks in advance

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.