-3

how to display all tables name from mysql database using php? I am using this syntax.. can anybody guide me where i m wrong.. thanks in advance

    <?php

$db = mysqli_connect('localhost','root','','realestate');

// Check connection
if (mysqli_connect_errno($db))
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
  else 
  {
  echo "Successfully connected to database.</br>";
  }

  $result = mysql_query("SHOW TABLES FROM 'realestate'");

  while ($row = mysql_fetch_array($result))
  {
  echo $row[0];
  }


  ?>
4
  • Do you get an error? A white screen? What does mysql_error() give you? Commented Nov 5, 2013 at 20:09
  • select from information_schema Commented Nov 5, 2013 at 20:10
  • I'm not pretty sure, but I guess the quotes are unnecessary at database name in your query. Also you could do "SHOW TABLES" only as well, because database name was already specified. Commented Nov 5, 2013 at 20:12
  • Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\00000\tables2.php on line 17 Commented Nov 5, 2013 at 20:17

1 Answer 1

2

1.You are mixing mysqli with mysql

2.Use backticks for table,database or column names

SHOW TABLES FROM `realestate`
Sign up to request clarification or add additional context in comments.

1 Comment

sir, its giving me error that mysql_fetch_array() expects parameter 1 to be resource, boolean given and all

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.