PDA

Vollstndige Version anzeigen : mysql_query("SHOW DATABASES") ohne Connection?!?


chris17
23-07-2004, 16:50
Hallihallo,

ist das "normal", da diese Zeilen ohne mysql_connect() funktionieren?

$res = mysql_query("SHOW DATABASES");

while ($row = mysql_fetch_assoc($res)) {
echo $row['Database'].'<br>';
$res_t = mysql_query("SHOW TABLES FROM {$row['Database']}");
while ($row_t = mysql_fetch_row($res_t)) {
echo '&nbsp;- '.$row_t[0].'<br>';
}
}

(WAMP mit php 4.3.7)

xabbuh
23-07-2004, 18:23
Scheint so.

Bei mir (WAMP, php 4.3.3) funktioniert es auch ohne mysql_connect().

chris17
29-07-2004, 10:39
Hallo xabbuh,

Danke fr Deine Antwort. Ich find das schon bissl "komisch", dass das funktioniert.
An welcher Einstellung knnte denn das liegen?

Gruss

Christian

xabbuh
29-07-2004, 12:34
Gute Frage. Vielleicht ist das aber auch standard und nicht vernderbar?!

Gru Christian

xabbuh
30-07-2004, 10:48
Habe bei mir in der php.ini gefunden. Vielleicht hilft dir das weiter.



Default port number for mysql_connect(). If unset, mysql_connect() will use
; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the
; compile-time value defined MYSQL_PORT (in that order). Win32 will only look
' at MYSQL_PORT.
mysql.default_port =

; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
mysql.default_socket =

; Default host for mysql_connect() (doesn't apply in safe mode).
mysql.default_host =

; Default user for mysql_connect() (doesn't apply in safe mode).
mysql.default_user =

; Default password for mysql_connect() (doesn't apply in safe mode).
; Note that this is generally a *bad* idea to store passwords in this file.
; *Any* user with PHP access can run 'echo cfg_get_var("mysql.default_password")
; and reveal this password! And of course, any users with read access to this
; file will be able to reveal the password as well.
mysql.default_password =

sniechzial
04-08-2004, 00:19
Hi,

interessante Feststellung die du da gemacht hast... scheint so auch nicht dokumentiert zu sein.

Hab mal etwas rumprobiert, sowohl unter Windows als auch unter Linux.
Wenn man mysql_query() aufruft, ohne defaults in der php.ini (wie im ersten Post) und ohne vorheriges connect... versucht php sich mit [WEBSERVER_BENUTZERNAME]@localhost auf mySQL zu verbinden.

Warning: Access denied for user: 'wwwrun@localhost' (Using password: NO) in /intranet/www/www10013/***/http-docs/lc_test.php on line 9


In deiner Config sind die Benuternamen anscheinend passend und du hast kein Passwort... also gehts.

MfG,
simon

chris17
04-08-2004, 12:31
Hi,

In deiner Config sind die Benuternamen anscheinend passend und du hast kein Passwort... also gehts.

Ich htte natrlich schreiben sollen, da ich fr root ein Passwort gesetzt habe.

Aber ich hab mir die DB "mysql" dann doch mal genauer angeschaut. :-)

In der Tabelle "user" hab' ich den beltter ausgemacht.

Dort gibt's (anscheinend standardmssig?!?) einen Eintrag:
Host: localhost
User: LEER
password: LEER
Rechte: Von "Select_priv" bis "Alter_priv" YES

Wenn ich den User bearbeite/lsche, dann funktionert das Skript oben nicht mehr.


Vielen Dank fr Eure Antworten

Gru

Christian