Buongiorno a tutti mi sto avvicinando per le prime volte al php per un progetto e avrei bisogno di una mano...
Ho bisogno di connettermi al database ma mi da degli strani warning e nn si connette...
Vi mettoo un po di codice per capirci...
L'errore che mi ritorna è questo:
Notice: Undefined variable: hostname in /chroot/home/S3654125/public_html/functions/mysqldb.php on line 17 Notice: Undefined variable: username in /chroot/home/S3654125/public_html/functions/mysqldb.php on line 17 Notice: Undefined variable: password in /chroot/home/S3654125/public_html/functions/mysqldb.php on line 17 Notice: Undefined variable: dbname in /chroot/home/S3654125/public_html/functions/mysqldb.php on line 17 Warning: mysqli::mysqli(): (28000/1045): Access denied for user 'www-data'@'localhost' (using password: NO) in /chroot/home/S3654125/public_html/functions/mysqldb.php on line 17 Non riesco a connettermi: 1045 Warning: mysql_real_escape_string(): Access denied for user 'www-data'@'localhost' (using password: NO) in /chroot/home/S3654125/public_html/functions/mysqldb.php on line 75 Warning: mysql_real_escape_string(): A link to the server could not be established in /chroot/home/S3654125/public_html/functions/mysqldb.php on line 75 Warning: mysql_real_escape_string(): Access denied for user 'www-data'@'localhost' (using password: NO) in /chroot/home/S3654125/public_html/functions/mysqldb.php on line 76 Warning: mysql_real_escape_string(): A link to the server could not be established in /chroot/home/S3654125/public_html/functions/mysqldb.php on line 76 Warning: mysql_real_escape_string(): Access denied for user 'www-data'@'localhost' (using password: NO) in /chroot/home/S3654125/public_html/functions/mysqldb.php on line 77 Warning: mysql_real_escape_string(): A link to the server could not be established in /chroot/home/S3654125/public_html/functions/mysqldb.php on line 77 string(49) "SELECT * FROM users WHERE user='' and password=''" Warning: mysql_query(): Access denied for user 'www-data'@'localhost' (using password: NO) in /chroot/home/S3654125/public_html/functions/mysqldb.php on line 81 Warning: mysql_query(): A link to the server could not be established in /chroot/home/S3654125/public_html/functions/mysqldb.php on line 81 Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /chroot/home/S3654125/public_html/functions/mysqldb.php on line 83
Riuscite a darmi un consiglio perchè è molto importante e nn riesco a trovare una soluzione.
Grazie
Ho bisogno di connettermi al database ma mi da degli strani warning e nn si connette...
Vi mettoo un po di codice per capirci...
PHP:
<?php
class mysqlClass
{
// parametri per la connessione al database
private $hostname = "localhost";
private $port = "5670";
private $dbname = "pinco";
private $username = "palla";
private $password = "prrrrr";
// controllo sulle connessioni attive
private $active = false;
private $conn;
// funzione per la connessione a MySQL
public function connect()
{ // connessione al DBMS
$con= new mysqli($hostname, $username, $password, $dbname);
if( mysqli_connect_errno())
{
echo ('Non riesco a connettermi: ' . mysqli_connect_errno() );
}
else{
echo ("Ti sei connesso al database"." ".$db);
}
}
public function checklogin($username, $password){
// Nome utente e password inviate attraverso il form
// To protect MySQL injection (more detail about MySQL injection)
$username = stripslashes($username);
$password = md5(mysql_real_escape_string($password));
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$sql="SELECT * FROM users WHERE user='$username' and password='$password'";
var_dump($sql);//qui verifichi se la query viene scritta giusta
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $username and $password, table row must be 1 row
if($count==1){
// Register $username, $password and redirect to file "login_success.php"
return TRUE;
}
else {
return FALSE;
}
}
}
?>
L'errore che mi ritorna è questo:
Notice: Undefined variable: hostname in /chroot/home/S3654125/public_html/functions/mysqldb.php on line 17 Notice: Undefined variable: username in /chroot/home/S3654125/public_html/functions/mysqldb.php on line 17 Notice: Undefined variable: password in /chroot/home/S3654125/public_html/functions/mysqldb.php on line 17 Notice: Undefined variable: dbname in /chroot/home/S3654125/public_html/functions/mysqldb.php on line 17 Warning: mysqli::mysqli(): (28000/1045): Access denied for user 'www-data'@'localhost' (using password: NO) in /chroot/home/S3654125/public_html/functions/mysqldb.php on line 17 Non riesco a connettermi: 1045 Warning: mysql_real_escape_string(): Access denied for user 'www-data'@'localhost' (using password: NO) in /chroot/home/S3654125/public_html/functions/mysqldb.php on line 75 Warning: mysql_real_escape_string(): A link to the server could not be established in /chroot/home/S3654125/public_html/functions/mysqldb.php on line 75 Warning: mysql_real_escape_string(): Access denied for user 'www-data'@'localhost' (using password: NO) in /chroot/home/S3654125/public_html/functions/mysqldb.php on line 76 Warning: mysql_real_escape_string(): A link to the server could not be established in /chroot/home/S3654125/public_html/functions/mysqldb.php on line 76 Warning: mysql_real_escape_string(): Access denied for user 'www-data'@'localhost' (using password: NO) in /chroot/home/S3654125/public_html/functions/mysqldb.php on line 77 Warning: mysql_real_escape_string(): A link to the server could not be established in /chroot/home/S3654125/public_html/functions/mysqldb.php on line 77 string(49) "SELECT * FROM users WHERE user='' and password=''" Warning: mysql_query(): Access denied for user 'www-data'@'localhost' (using password: NO) in /chroot/home/S3654125/public_html/functions/mysqldb.php on line 81 Warning: mysql_query(): A link to the server could not be established in /chroot/home/S3654125/public_html/functions/mysqldb.php on line 81 Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /chroot/home/S3654125/public_html/functions/mysqldb.php on line 83
Riuscite a darmi un consiglio perchè è molto importante e nn riesco a trovare una soluzione.
Grazie
Ultima modifica di un moderatore: