0

I have installed XAMPP which as you know automatically installs Apache , PHP and MySQL , that's the reason why I don't know my user name and password when I am trying to conect the database using PHP file. I have written this PHP function which has to connect to the database:

http://postimg.org/image/wgq35omfd/

I have entered phpMyAdmin and have seen the users and I see one named root , I know the server is called localhost but I don't know the pasword and I can't pass the correct data to the database connect function mysql_pconnect("localhost" , "root", pass ) and that's why my function always returns false. How can I check which are the username and the pasword to pass it to the mysql_pconnect function.

aynber
  • 22,380
  • 8
  • 50
  • 63
Montoolivo
  • 137
  • 2
  • 3
  • 15
  • 2
    You are using [an **obsolete** database API](http://stackoverflow.com/q/12859942/19068) and should use a [modern replacement](http://php.net/manual/en/mysqlinfo.api.choosing.php). – Quentin Aug 17 '14 at 15:52

1 Answers1

-1

If you've entered phpMyAdmin you should know your username and password. Use those. If you entered phpMyAdmin without a password then the password should be blank. (Try to put a password on it tho.)

Triplus
  • 126
  • 9
  • So if my password is blank I have to type the mysql_pconect function like that mysql_pconect("localhost" , "root"); Is that right? – Montoolivo Aug 17 '14 at 15:54
  • I don't use the pconnect function myself, but I found it is going to be deprecated soon (or already is). Try this instead, it has some nice documentation aswell.http://www.w3schools.com/php/php_mysql_connect.asp – Triplus Aug 17 '14 at 15:57
  • Typing like that mysqli_connect("localhost" , "root" ); is still giving me error . – Montoolivo Aug 17 '14 at 16:04
  • Try putting NULL as the password (without "") Like this ('localhost', 'root', NULL, 'dbname') – Triplus Aug 17 '14 at 16:06
  • It's telling me that the database is unknown when I have entered the phpAdmin and I have seen the database. – Montoolivo Aug 17 '14 at 16:16
  • Did you fill in the 'dbname'? Try with the same capital letters. – Triplus Aug 17 '14 at 16:29
  • Yes I filled in the dbname. What do you mean by "Try with the same capital letters." – Montoolivo Aug 17 '14 at 16:36
  • If your db is named DBname also type DBname and not dbName. If it still doesn't work post some code. – Triplus Aug 17 '14 at 16:38
  • Yes I am typing the exact same name in the mysql_conect function. Here is my function http://postimg.org/image/5wjwkfdpp/ and it always returns false – Montoolivo Aug 17 '14 at 16:50
  • `//connection to the database $dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL"); $table = "DbName"; $selected = mysql_select_db($table, $dbhandle) or die("Could not select database");` – Triplus Aug 17 '14 at 16:57
  • Where do I have to put that ? In my db_connect function? – Montoolivo Aug 17 '14 at 16:59
  • Try only that, if you have no messages on your screen it works now. You don't really need a function for what you are doing. – Triplus Aug 17 '14 at 17:00
  • OK , but where do I put what you've typed in ? – Montoolivo Aug 17 '14 at 17:02
  • at the moment u are tyring to connect to ur database, you could but it in the function if u wish. I always use an include. – Triplus Aug 17 '14 at 17:07