Bonjour
Je voudrais tester si ma connexion à MySQL fonctionne correctement. Comment puis-je faire ?
J'ai fais ce code mais je pense qu'il ne fonctionne pas.
Je précise que je suis un grand débutant en JScript (dailleurs si quelqu'un a une URL d'un bon cours, je suis preneur)
Si ca peux vous aidez, je cherche à traduire ce code PHP en Jscript :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 var bdname = Request.Form("bdname") ; var username = Request.Form("username") ; var userpass = Request.Form("userpass") ; var root = Request.Form("root") ; var rootpass = Request.Form("rootpass") ; var err ; var strConn = "Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=mysql; User=root;Password=;Option=3;" ; var conn = Server.CreateObject("ADODB.Connection") ; try { conn.ConnectionString = strConn ; conn.Open() ; Response.Write("ok"); } catch( err ) { Response.Write(root + " " + err.description); }
Ce code n'est pas bien compliqué mais je galère vraiment en JScript ^^
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 <? $bdname = $_POST["bdname"] ; $username = $_POST["username"] ; $userpass = $_POST["userpass"] ; $root = $_POST["root"] ; $rootpass = $_POST["rootpass"] ; $connect = mysql_pconnect('localhost',$root,$rootpass) ; $sql = "CREATE DATABASE IF NOT EXISTS $bdname"; $req = mysql_query($sql) or die(mysql_error()); $cnx = mysql_select_db('mysql',$connect); $sql = "SELECT User From user where User = '$username'"; $req = mysql_query($sql) or die(mysql_error()); $recup = mysql_fetch_array($req) ; if($recup['User'] == ''){ $sql = "CREATE USER '$username' IDENTIFIED BY '$userpass';" ; mysql_query($sql) or die(mysql_error()) ; $sql = 'GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,INDEX,DROP,ALTER ON `'.$bdname.'`.* TO \''.$username .'\'@\'%\';'; $req = mysql_query($sql) or die(mysql_error()) ; } $sql = "update user set Password=OLD_PASSWORD('$userpass') where User='$username'" ; $req = mysql_query($sql) or die(mysql_error()) ; $sql = 'FLUSH PRIVILEGES;'; $req = mysql_query($sql) or die(mysql_error()) ; ?>
Voila, donc si quelqu'un pouvez me dire comment tester ma connexion, ca serait sympas.
Merci d'avance.
bdaboah
Partager