Hello
I'm trying to implement a login function that allows me to extract data from facebook and save them on my moodle Website. Unfortunately, I'm not a programmer and I'm having some problems. In particular, I'm having some difficulties -I believe- related to the permission rights when I try to "write" the data extracted from fb on a MySQL database.
This is what I have done so far:
I managed to extract from Fb the data that interest me and I tried to save them to a MySQL database (created through cpannel). The code I used to access the database is basically this (with the correct parameters for my database):
// Create connection
$ Db = new mysqli ($ localhost, $ username, $ password, $ database);
// Check connection
if ($ db> connect_error) {
die ( "Connection failed:". $ db-> connect_error);
}
But when I connect to the web page I get this error: "Connection failed: Access denied for user 'root' @ 'localhost' (using password: NO)"
The problem seems to be that the user/pass are incorrect. In fact, I am sure the data correspond to those included in CPannel by me at the time of database creation. The associated user has all active privileges.
I did some research and it it seemed that the problem could be associated with some "automatic" setting of Moodle. So I uninstalled moodle but nothing has changed.
I also tried to change the code:
$config = parse_ini_file('/config.ini');
// Connect to database
$mysqli = new mysqli($config['servername'], $config['username'], $config['password'], $config['dbname']);
printf("\n ".date("Y-m-d h:i:sa") . " - Establishing connection to " . $config['dbname'] . " on " . $config['servername'] . ".\n");
// Check connection
if ($mysqli->connect_error) {
die('Error : (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error);
printf("\n ".date("Y-m-d h:i:sa") . " - Connection failed. Returned error: " . mysqli_connect_error() . "\n");
} else {
printf("\n ".date("Y-m-d h:i:sa") . " - Connection successful.\n");
}
Unfortunately I had no luck ...
This is the tutorial i followed to implement the function:
https://www.youtube.com/watch?v=N5Kka43giyY&index=30&list=PLmpuiTmSb3xCLwwkpXeuJxwKyljf7e3Tx
I am very inexperienced, but it seems to me that the problem arises when I define password in cpannel ... it is as if the password had no value ..
Any ideas on how I can resolve it?
Greetings,
Ema
I'm trying to implement a login function that allows me to extract data from facebook and save them on my moodle Website. Unfortunately, I'm not a programmer and I'm having some problems. In particular, I'm having some difficulties -I believe- related to the permission rights when I try to "write" the data extracted from fb on a MySQL database.
This is what I have done so far:
I managed to extract from Fb the data that interest me and I tried to save them to a MySQL database (created through cpannel). The code I used to access the database is basically this (with the correct parameters for my database):
// Create connection
$ Db = new mysqli ($ localhost, $ username, $ password, $ database);
// Check connection
if ($ db> connect_error) {
die ( "Connection failed:". $ db-> connect_error);
}
But when I connect to the web page I get this error: "Connection failed: Access denied for user 'root' @ 'localhost' (using password: NO)"
The problem seems to be that the user/pass are incorrect. In fact, I am sure the data correspond to those included in CPannel by me at the time of database creation. The associated user has all active privileges.
I did some research and it it seemed that the problem could be associated with some "automatic" setting of Moodle. So I uninstalled moodle but nothing has changed.
I also tried to change the code:
$config = parse_ini_file('/config.ini');
// Connect to database
$mysqli = new mysqli($config['servername'], $config['username'], $config['password'], $config['dbname']);
printf("\n ".date("Y-m-d h:i:sa") . " - Establishing connection to " . $config['dbname'] . " on " . $config['servername'] . ".\n");
// Check connection
if ($mysqli->connect_error) {
die('Error : (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error);
printf("\n ".date("Y-m-d h:i:sa") . " - Connection failed. Returned error: " . mysqli_connect_error() . "\n");
} else {
printf("\n ".date("Y-m-d h:i:sa") . " - Connection successful.\n");
}
Unfortunately I had no luck ...
This is the tutorial i followed to implement the function:
https://www.youtube.com/watch?v=N5Kka43giyY&index=30&list=PLmpuiTmSb3xCLwwkpXeuJxwKyljf7e3Tx
I am very inexperienced, but it seems to me that the problem arises when I define password in cpannel ... it is as if the password had no value ..
Any ideas on how I can resolve it?
Greetings,
Ema