Cant connect databse

Status
Not open for further replies.

lolmedia

Member
Messages
32
Reaction score
0
Points
6
Hi,
I can't connect to my database from my website :
this is my connection script :
PHP:
<?php
 $server="localhost";
$bdd="********";
    $user="******@localhost"; /* or localhost ?*/
    $password="********"; /* should I use a encrypt function ? if yes, what encrypt function ? I think that phpmyadmin is not using md5 lol , to easy to hack ...*/

    $connexion=mysql_pconnect($server, $user);
        if(!$connexion){
        echo "pas de connexion" ; exit; /*traduction : no connection */
   }                    
if(!mysql_select_db($bdd, $connexion)){
        echo "pas d'accès à la base"; exit;    /*cannot acces database*/
}
?>

thank for help !
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
1. You should think about starting to use PDO instead of the mysql_ interface

2. mysql_pconnect ( server, user, password ) ... I don't see you using the password (no, you do not encrypt it)

3. server = 'localhost'

4. user and password should be the user and password you created via cPanel --> MySQL Databases. Remember to add the user to your database with ALL PRIVILEGES. You can use your cPanel username and password, but that is not considered secure.

5. Databases and usernames created via MySQL Databases are of the form cPanelUsername_foo where 'foo' is the specific name you gave them.
 

lolmedia

Member
Messages
32
Reaction score
0
Points
6
please can a moderator, delete this thread, I resolved the problem, I just forgot to put the password in mysql_pconnect() rofl
 
Status
Not open for further replies.
Top