The example is wrong in Spanish version.
ERROR: mysql_fetch_assoc() expects parameter 1 to be resource, null given in XXX on line 5
while ($fila = mysql_fetch_assoc($res)) {
OK.
while ($fila = mysql_fetch_assoc($resultado)) {
(PHP 4, PHP 5)
mysql_list_dbs — MySQL 서버에 있는 데이터베이스 목록을 반환
$link_identifier
] )MySQL 데몬으로부터 데이터베이스 목록을 포함하는 결과 포인터를 반환한다.
link_identifier
MySQL
연결. 지정하지 않으면 mysql_connect()로 연 마지막 연결을
사용합니다. 연결이 없으면, 인수 없이 mysql_connect()를
호출하여 연결을 만듭니다. 연결이 성립되지 않으면
E_WARNING
등급의 오류를
생성합니다.
성공하면 resource 결과 포인터를 반환하고,
실패하면 FALSE
를 반환한다.
결과 포인터를 탐색하기 위해 mysql_tablename()를 사용하거나,
mysql_fetch_array()와 같은 결과 테이블을 위한 특정 함수를
사용한다.
Example #1 mysql_list_dbs() 예제
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
$db_list = mysql_list_dbs($link);
while ($row = mysql_fetch_object($db_list)) {
echo $row->Database . "\n";
}
?>
위 예제의 출력 예시:
database1 database2 database3
Note:
하위 호환을 위하여, 다음의 권장하지 않는 별칭을 사용할 수 있습니다: mysql_listdbs()
The example is wrong in Spanish version.
ERROR: mysql_fetch_assoc() expects parameter 1 to be resource, null given in XXX on line 5
while ($fila = mysql_fetch_assoc($res)) {
OK.
while ($fila = mysql_fetch_assoc($resultado)) {
Another alternative to this function is:
SQL Query: SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA
The result pointer contains only the databases for which the mysql_user has the select priviledge granted.