12 Replies - 1240 Views - Last Post: 10 September 2009 - 09:05 AM

#1 mikecheer101   User is offline

  • D.I.C Head

Reputation: -9
  • View blog
  • Posts: 114
  • Joined: 12-June 09

Connection Error

Posted 08 September 2009 - 02:47 PM

im trying to connect my database to my website
<?php

$db = mysql_connect("localhost","root","") or die("Could not connect to db");
if(!$db)
die("no db");
if(!mysql_select_db("a3693917_123",$db))
die("No Database Selected");

?>
thats the connecting code
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'players'@'localhost' (using password: NO) in /home/a3693917/public_html/connect.php on line 3

Free Web Hosting
Could not connect to db
thats the error message i get

Is This A Good Question/Topic? 0
  • +

Replies To: Connection Error

#2 tommyflint   User is offline

  • D.I.C Addict
  • member icon

Reputation: 34
  • View blog
  • Posts: 679
  • Joined: 24-July 08

Re: Connection Error

Posted 08 September 2009 - 03:15 PM

Well in your mysql_connect function it says your using the user name "root" but then in the error it says you tried to make a connection using the user name "players" are you sure you have your usernames correct in the right php file
Was This Post Helpful? 0
  • +
  • -

#3 mikecheer101   User is offline

  • D.I.C Head

Reputation: -9
  • View blog
  • Posts: 114
  • Joined: 12-June 09

Re: Connection Error

Posted 08 September 2009 - 03:27 PM

o my bad
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: NO) in /home/a3693917/public_html/connect.php on line 3

Free Web Hosting
Could not connect to db

Was This Post Helpful? 0
  • +
  • -

#4 tommyflint   User is offline

  • D.I.C Addict
  • member icon

Reputation: 34
  • View blog
  • Posts: 679
  • Joined: 24-July 08

Re: Connection Error

Posted 08 September 2009 - 03:31 PM

Well its telling you your login details are incorrect
Was This Post Helpful? 0
  • +
  • -

#5 mikecheer101   User is offline

  • D.I.C Head

Reputation: -9
  • View blog
  • Posts: 114
  • Joined: 12-June 09

Re: Connection Error

Posted 08 September 2009 - 03:34 PM

im making a text based game though click register LINK
Was This Post Helpful? 0
  • +
  • -

#6 tommyflint   User is offline

  • D.I.C Addict
  • member icon

Reputation: 34
  • View blog
  • Posts: 679
  • Joined: 24-July 08

Re: Connection Error

Posted 08 September 2009 - 03:41 PM

i would contact your host to find out the correct login details
Was This Post Helpful? 0
  • +
  • -

#7 mikecheer101   User is offline

  • D.I.C Head

Reputation: -9
  • View blog
  • Posts: 114
  • Joined: 12-June 09

Re: Connection Error

Posted 08 September 2009 - 03:51 PM

i did they said:Hello,

Our team would be more than happy to help you with any problem you encounter. However, we will only provide free support for our system and services. We will help you with basic problems associated with getting scripts running, but if you need help with third-party software, contact the authors of that software or query Google.com with error message you get.

It is not possible for us to provide help for everyone, fix PHP errors or develop your website as it would require a lot of administrative time. We focus in getting our servers and services up and running.

However, you can upgrade your account at http://www.000webhost.com/upgrade and we will provide you with full help in installing your scripts, developing your website and fixing errors.
Was This Post Helpful? 0
  • +
  • -

#8 tommyflint   User is offline

  • D.I.C Addict
  • member icon

Reputation: 34
  • View blog
  • Posts: 679
  • Joined: 24-July 08

Re: Connection Error

Posted 08 September 2009 - 03:58 PM

have your created a mysql database at 000webhost yet?

tommyflint

This post has been edited by tommyflint: 08 September 2009 - 04:09 PM

Was This Post Helpful? 0
  • +
  • -

#9 mikecheer101   User is offline

  • D.I.C Head

Reputation: -9
  • View blog
  • Posts: 114
  • Joined: 12-June 09

Re: Connection Error

Posted 08 September 2009 - 04:18 PM

i fixed it, was i supposed to enter my mysql information in the code?
Was This Post Helpful? 0
  • +
  • -

#10 mikecheer101   User is offline

  • D.I.C Head

Reputation: -9
  • View blog
  • Posts: 114
  • Joined: 12-June 09

Re: Connection Error

Posted 09 September 2009 - 12:00 PM

i made this website and when i click register and enter the info and click submit it says "Could not query players table" and i dont know why i have a players table in my phpmyadmin
Was This Post Helpful? 0
  • +
  • -

#11 tommyflint   User is offline

  • D.I.C Addict
  • member icon

Reputation: 34
  • View blog
  • Posts: 679
  • Joined: 24-July 08

Re: Connection Error

Posted 09 September 2009 - 02:19 PM

if you post the code we may be able to help more?

tommyflint
Was This Post Helpful? 0
  • +
  • -

#12 mikecheer101   User is offline

  • D.I.C Head

Reputation: -9
  • View blog
  • Posts: 114
  • Joined: 12-June 09

Re: Connection Error

Posted 09 September 2009 - 05:19 PM

Register User Code
<?php
include 'connect.php';
?>
 
<?php
$player=$_POST['player'];
$password=$_POST['password'];
$pass2=$_POST['pass2'];
$player=strip_tags($player);
$email=$_POST['email'];
$email=strip_tags($email);
 
if ($email == "")
{
echo "You didn't enter a email address!<br>";
echo " <A href='register.php'>Go back</a>";
	exit;
	}
if ($password==$pass2)
{
 
  $isplayer="SELECT * from players where name='$player'";
  $isplayer2=mysql_query($isplayer) or die("Could not query players table");
  $isplayer3=mysql_fetch_array($isplayer2);
  if(!$_POST['password'] || !$_POST['pass2'])
  {
	 print "You did not enter a password";
	echo " <A href='register.php'>Go back</a><br>";
	exit;
  }
  else if($isplayer3 || strlen($player)>15 || strlen($player)<1)
  {
	 print "There is already a player of that name or the name you specified is over 16 letters or less than 1 letter<br>";
	 echo " <A href='register.php'>Go back</a>";
	exit;
  }
  else
  {
	$isaddress="SELECT * from players where email='$email'";
	$isaddress2=mysql_query($isaddress) or die("not able to query for password");
	$isaddress3=mysql_fetch_array($isaddress2);
	if($isaddress3)
	{
	  print "There is already a player with that e-mail address<br>";
	  echo " <A href='register.php'>Go back</a>";
	exit;
	}
	else
	{
		$password=md5($password);
 
$SQL = "INSERT into players(name, password, email) VALUES ('$player','$password','$email','1','0')"; 
	  mysql_query($SQL) or die("could not register");
 
	  print "Thank you for registering.";
 
	}
  }
}
 
else
{
  print "Your password didn't match or you did not enter a password<br>";
   echo " <A href='register.php'>Go back</a>";
	exit;
}
echo "<br><A href='login.php'>Login Page</a>";
?>

Register code
<?php
include 'connect.php';
 
?>
 
<form method="post" action="reguser.php">
Username: <input type="text" name="player" size="21"><br>
Password: <input type="password" name="password" size="15"<br>
Confirm Pass: <input type="password" name="pass2" size="15" maxlength="20" value=""/><br> 
Email Address: <input type="text" name="email" size="40" maxlength="65"<br>
Confirm Email: <input type="text" name="email2" size="40" maxlength="65" value""/><br>
Gym Name: <input type="text" name="gym name" size="20"<br>
<input type="submit" value="submit"><br>
</form>

Was This Post Helpful? 0
  • +
  • -

#13 gregwhitworth   User is offline

  • Tired.
  • member icon

Reputation: 221
  • View blog
  • Posts: 1,613
  • Joined: 20-January 09

Re: Connection Error

Posted 10 September 2009 - 09:05 AM

Well first off - are you positive that you are connecting to the database? Do you have an "or die" after the connection script so that you know that you are connected?

I see it on the query but I can't see your connection code (don't post with real credentials) - so I thought I'd ask.

--

Greg
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1