hi everuone i have website but i cant connect to database for login & register how can i connect? here my code

<?php
$connect=mysql_connect("184.154.164.202","ahmedhay_royal","xxxxxxx") or die("couldnt connect to data base:".mysql_error());
mysql_select_db("ahmedhay_login",$connect) or die ("couldnt find data base");

?>

Recommended Answers

All 16 Replies

What error message do you get?

they show me this error
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'ahmedhay_royal'@'server2.websitehostserver.net' (using password: YES) in /home/ahmedhay/public_html/dbc.php on line 2
couldnt connect to data base:Access denied for user 'ahmedhay_royal'@'server2.websitehostserver.net' (using password: YES)

If you are running this code on your webhost, then try "localhost" instead of the IP address. If you are running this elsewhere, you may not have priviliges to access your MySQL remotely. Ask your webhost.

thanx alot but i havr manyyy error after login but i test it in wamp server ti work why in my website not working?

and my register still not working

Access denied for user 'ahmedhay_royal'@'server2.websitehostserver.net'

Change the user to the correct one, with the right password, and change the server to localhost.

try chaning the ip address to server2.websitehostserver.net

It also happened to me.

Try putting this to your mysql.ini
In the SERVER SECTION, under [mysqld],add this line

skip-grant-tables

hi now my websit is work now only my register.php how can i fix it?here my code

<?php
error_reporting(0);
   if($_POST['submit'])
{
  $fullname=mysql_real_escape_string($_POST['fullname']);
  $username=mysql_real_escape_string($_POST['username']);
  $password=mysql_real_escape_string($_POST['password']);
  $password1=mysql_real_escape_string($_POST['password1']);
$enc_Password=md5($password);
if($fullname && $username &&$password &&$password1)
   {
   if(strlen($fullname)>30)

   {
   echo "your name is too long";
   }
   if(strlen($username)>30)
   {
      echo "your username is too long";
   }
   else
   {
   if(strlen($password)>15 || strlen($password)<6)
   {
      echo "your password must be btween 6 and 15 character";
   }
   if($password == $password1)
   {
       require "dbc.php";
       $query = mysql_query("INSERT INTO tala  VALUES (NULL, '$fullname', '$username', '$enc_Password')") or die(mysql_error());

      die(  header("location: index.php"));
   }
   else
   {
   echo "password must match";
   }
   }
   }
   else
   echo "all fileds are required";
}
?>

What error message do you see?

In your code I do not see you making a connection to MySQL.

when i register they tell all fileds are required the message in 41

they tell me the message in line 41 all fileds are required

That means this if($fullname && $username &&$password &&$password1) fails.

so what i have to write?by the way i didn't insert password1 in my database only
password varchar(30)

aisha.edris1

did we helped you in your first problem?

Yes my first problem it solved but my register doesn't workkk and i must deliver my project tomorrow to my super viser i don't know what i have suppose to do to solve this problem???

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.