-1

Hello i still getting this error...can anyone explain me why is there 10.2.1.19? because in my config db file there is localhost instead of 10.2.1.19..i tried to type 127.0.0.1 instead of localhost but nothing...still 10.2.1.19

My configdb file:

 <?php
 $mysqli=mysqli_connect('127.0.0.1','user','','table') or die(mysqli_error($mysqli));
?>

Thanx for help

Niranjan N Raju
  • 12,047
  • 4
  • 22
  • 41
FreeDay
  • 21
  • 1
  • 1
  • 8
  • 1
    Are you sure that error is coming from that line of code? Both the host and the username are different. I'm pretty sure it's not! – Luke Cousins Oct 10 '15 at 10:51
  • Do you think that this isn´t from configdb file? i check other files and let you know... – FreeDay Oct 10 '15 at 10:56
  • check your hosts file (c:\Windows\System32\Drivers\etc\hosts).. maybe localhost is declared as `10.2.1.19` there, or the .htaccess file in your project – Zoltan Toth Oct 10 '15 at 11:13
  • @ZoltanToth i checked it and nothing...my localhost name is declared as `127.0.0.1` or `::1` – FreeDay Oct 10 '15 at 11:19

2 Answers2

2

Maybe because of User name and password. Pass valid username, password and DB Name

<?php
$con = mysqli_connect("localhost","my_user","my_password","my_db");

// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
?>
Jitendra Kumar. Balla
  • 1,173
  • 1
  • 9
  • 15
  • Hello, now i getting error `Failed to connect to MySQL: Access denied for user 'revenge'@'10.2.1.19' (using password: NO)` ...i checked my username and password in phpmyadmin and its correct...still _10.2.1.19_ – FreeDay Oct 10 '15 at 11:05
  • http://stackoverflow.com/questions/6445917/connect-failed-access-denied-for-user-rootlocalhost-using-password-yes This link may be helpful for you. – Jitendra Kumar. Balla Oct 10 '15 at 11:13
  • Thanx for reply i try it and let you know – FreeDay Oct 10 '15 at 11:20
  • i tried and nothing...still getting same error :/ – FreeDay Oct 10 '15 at 11:41
1

Your code is:

<?php
 $mysqli=mysqli_connect('127.0.0.1','user','','table') or die(mysqli_error($mysqli));
?>

You must to connect do database before try table

<?php
 $mysqli=mysqli_connect('127.0.0.1','user','','DATABASE_NAME_HERE') or die(mysqli_error($mysqli));
?>

If this still doesn't work, try to set some password, '123' for example, and try connection again. I recommend you to use mysqli class:

$some_variable_name = new mysqli('server_name','user_name','password','database_name');
$some_sql_command = "your SQL without ; at final";
$some_variable_name->query($some_sql_command);
$some_variable_name->close();

Go to php.net manual and see all commands.

I'm not an expert in configs, .ini files and these things, so I can't tell nothing about the modified IP.

Enrique René
  • 510
  • 1
  • 5
  • 19