[Tech] Help programmazione web ...

Massimiliano Masi max@mascanc.net
Sab 23 Mar 2002 14:15:22 CET


Salve !!!

su mascanc.net sto facendo delle utility php per far settare le acl di afs
e kerberos V
e la creazione di database mysql.

In MySQL ho messo grant all on *.* to root@shamt.mascanc.net identified by "password";

Quindi per l'utente root@shamt ho tutti i privilegi su tutto.

Con questo script:

<?
        $dbp = mysql_connect("islands.mascanc.net", "root", "password");
        if (!$dbp) { print mysql_errno().": ".mysql_error(); die(); }

if (ereg("^[a-z0-9][a-z0-9][a-z0-9][a-z0-9]([a-z0-9][a-z0-9][a-z0-9][a-z0-9])*", $db)) { print "Dbname regexp OK !!!<br>";
}
else { print "Dbname must be a-z0-9"; die(); }

if (strlen($db)==0) { print "Insert the name of the db"; die(); }
if (strlen($db)>10) { print "The lenght of the string dbname must be < 10"; die(); }

        mysql_select_db("mascanc");
        $stmt = "select * from users where userid = '$username' and password = '$password'";
        $sth = mysql_query($stmt);
        if (!$sth) { print mysql_errno().": ".mysql_error(); die(); }
        $row = mysql_fetch_object($sth);
        if ($row->userid=='') { print "Username or password mistaken"; die(); }

        // OK l'utente esiste. Gli creo il database.
        // Controllo che esista.
        $stmt = "CREATE DATABASE $db";
        $sth = mysql_query($stmt);

        if (!$sth) { print mysql_errno().": ".mysql_error(); die(); }
        $stmt = "FLUSH PRIVILEGES";
         $sth = mysql_query($stmt);

        if (!$sth) { print mysql_errno().": ".mysql_error(); die(); }

        $stmt = "GRANT ALL on ".$db.".* to $row->userid"."@shamt.mascanc.net IDENTIFIED BY '$row->password'";
        $sth = mysql_query($stmt);
        if (!$sth) { print mysql_errno().": ".mysql_error(); }

        mysql_close($dbp);
// testo la connessione

        $dbp = mysql_connect("islands.mascanc.net", "$row->userid", "$row->password");
        if (!$dbp) { print mysql_errno().": ".mysql_error(); die(); }
        $dbh = mysql_select_db("$db");
        if (!$dbh) { print mysql_errno().": ".mysql_error(); die(); }
	print "CONNESSIONE EFFETTUATA!!! IL DB E' CREATO !!! Ora ti arrivera'
	una mail.";

?>


Non mi funziona. 
Mi da' questo errore:

Dbname regexp OK !!!
1044: Access denied for user: 'root@shamt.mascanc.net' to database 'provadb3'
Warning: Access denied for user: 'provadb@shamt.mascanc.net' (Using password: YES) in /var/www/db/1.php on line 35

Warning: MySQL Connection Failed: Access denied for user: 'provadb@shamt.mascanc.net' (Using password: YES) in /var/www/db/1.php on line 35
1045: Access denied for user: 'provadb@shamt.mascanc.net' (Using password: YES)

Con l'utente provadb. Come mai? Non fa il flush privileges? Help !!!





-- 
Massimiliano Masi - <max@MASCANC.NET> 

http://www.mascanc.net/~max/ - ... Anger is a gift ... 



Maggiori informazioni sulla lista flug-tech