V
V
Vahe2015-08-19 21:21:48
PHP
Vahe, 2015-08-19 21:21:48

Show all databases php not working?

The code works fine in the local server.

$result = mysql_query("SHOW DATABASES");        
while ($row = mysql_fetch_array($result)) {        
  echo $row[0]."<br>";        
}

But the website gives an error
Warning: mysql_fetch_array() expects parameter 1 to be resource

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Inchin ☢, 2015-08-19
@vahe_2000

1) Yeah, and it should also give out something like:
2) The request to the database did not return anything, $result is empty. Run error checking after the request and find out what's wrong.

$result = mysql_query("SHOW DATABASES");    
die(mysql_error());

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question