I have used the following code for connecting to my database in a php file.
$mysql_link = mysql_connect("localhost", "username", "password") ;
mysql_select_db('database') or die('Could not select database');
But I am getting an error like this.
Warning: mysql_connect() [function.mysql-connect]: Access denied for user ‘jppp_pvarier’@‘localhost’ (using password: YES) in /home/jppp/public_html/address-book/index.php on line 8
Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user ‘jppp’@‘localhost’ (using password: NO) in /home/jppp/public_html/address-book/index.php on line 9
Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/jppp/public_html/address-book/index.php on line 9
Could not select database
Just one doubt, my password begins with /* then contains a few letters and ends with */. I had been using this password sometime for some of my bank accounts, emai account etc and it was always considered to be a 100% strong password. I suddenly realised that when it comes to a php file, it may cause problems. Will it? Or do you think the problem lies somewhere else.
This works just fine, so the comment syntax can be applied inside strings without disturbing it. It may be an issue when it hits the MySQL functions though.
Try creating a user that has a text only password and see if that works with the same code.
if it were \ instead of /, i’d say you’d have trouble (\ is the escape character for double-quote strings).
The fact that it states you ARE sending a password with the request (Using password: YES) means your string is going through; You simply… have gotten something wrong. Check your username and password with your database admin.
Zarin Denatrose, I changed my password to exclude the escape comments, /* and /. Now I am able to connect to my database and am able to view my file. Does that mean that the signs, / and */ were indeed the problem?
Startliion, I have used / in both the places and not the other one.
Cups, thanks for the link on MySQL control data tables. It will be of help to a newbie like me. I was just trying to create a strong password and I just got a random thought that perhaps I could use the php comments.
I do not know what the problem was. But I tried once again with my original password ie the one starting with /* and ending with */ and I wanted to let you know that I am able to connect to my database now. Clearly, I was making some other newbie mistake though I am not able to find out what it was. In any case, my code is working now and i am able to view my file.