1
votes

the below error i m getting:

Warning: mysql_select_db(): Access denied for user 'nativepl'@'localhost' (using password: NO) in /home/nativepl/public_html/testing/search.php on line 177

Warning: mysql_select_db(): A link to the server could not be established in /home/nativepl/public_html/testing/search.php on line 177 Access denied for user 'nativepl'@'localhost' (using password: NO)

user: nativepl_search pwd:fun@123 database:nativepl_native table:search

 mysql_connect("localhost","nativepl_search","fun@123") or die("Error connecting to database: ".mysql_error());

 mysql_select_db("nativepl_native") or die(mysql_error());
2
I don't mean this flippantly, but have you double checked that the user has been granted access to the database? usually that's my problem when I get this type of error. Also I've never tried to put an underscore in a user name before, but your error message username stops before the '_search' part of the username you are using in the code. - Semicolons and Duct Tape
Using password: NO indicates no password was supplied. But your code shows you supplying a password. Do you have another mysql_connect() call in your code? I'm quite certain that the code above is not your current code. You probably have code in between the 2 lines above, or the error is not coming from these lines. Notice how the error indicates you are using username nativepl, whiel in your code you don't use this string at all. - nl-x
The underscore thing seemed weird. have you seen this? stackoverflow.com/questions/3928771/… it also would account for the no password issue. - Semicolons and Duct Tape

2 Answers

0
votes

Try This...

     $db = mysql_connect("localhost","nativepl_search","fun@123") or 
                  die("Error connecting to database: ".mysql_error());

     mysql_select_db("nativepl_native",$db) or die(mysql_error());
0
votes

The code you are showing above is incomplete. You probably have another line like mysql_connect("localhost","nativepl"); in between the two lines that you show above.

Or it can also be inside some function or include that you call in between those two lines.

Find it and remove it.