简体   繁体   中英

MySQL tables not found or not displayed

I have a webpage where I want to display some items updated from a database which in this case is mysql. The html for the list

<div id="right-column-sidebar-two">
<h3 id="header">Most</h3>
<ol>
<li><a href="#">R</a></li>
<li><a href="#">Q</a></li>
<li><a href="#">P</a></li>
<li><a href="#">O</a></li>
<li><a href="#">N</a></li>
<li><a href="#">M</a></li>
<li><a href="#">L</a></li>
<li><a href="#">K</a></li>
<li><a href="#">J</a></li>
<li><a href="#">I</a></li>
</ol>
</div>

These list items have been stored in my database and the combined mysql/php/html looks like this

<div id="right-column-sidebar">
<ol>
<?php
$link = mysql_connect("host", "user", "password");
mysql_select_db("db", $link);
$query = "SELECT * FROM `table_name` LIMIT 0, 30 ";
$result = mysql_query($query) or die (mysql_error());
while ($row = mysql_fetch_array($result)):
?><li><a href="#"> <?php echo $row['title']; ?></a></li>
<?php endwhile;
?>
</ol>
</div>

Now I have two tables I want to use in this case, I tried both of them separately and in a) I get no error messages, but nothing is displayed and in b) i get an error message saying that the table doesnt exist.

I don't know any mysql besides the code I just provided so its hard to determine what the causes might be. Would appreciate some tips.

First of all, don't use mysql_* , instead use mysqli or PDO .

As for your problem, from the first table, you are not getting any results because probably there is no data in the table.

In the second table you get the table not found error, since the table does not exist, meaning you got the table name wrong.

Can you access the DB with a GUI client like SqlYog or phpmyadmin? Try running your queries in this tool and see what you get.

If your phpMyAdmin no longer sees any tables in any of your local databases, that is because permissions change away from mysql.mysql on any database directory under /var/lib/mysql to, say, root.root (most probably). use this query to change the owner:

chown -R mysql.mysql /var/lib/mysql/*

tutorial via http://www.geckoandfly.com/7481/solution-for-no-tables-found-in-database-mysql-error-in-phpmyadmin/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM