duandong9195 2014-12-08 12:44
浏览 22
已采纳

MySQL:无法连接到表

I'm trying to connect my website to the MySQL table.

Here is my code;

<?php
$v1 = mysql_query('SELECT * FROM ('.$nompage.') ORDER BY id');
if($v1 === FALSE) {
    die('Erreur lors de la selection de la table.'); // TODO: meilleur erreur
}
while($liste = mysql_fetch_array($v1)){
?>

<tr>
<th><?php if(isset($liste['nom'])){
  echo $liste["nom"];} ?></th>
<th><a href="<?php echo $liste['lien1']; ?>"><i class="fa fa-external-link"></i>
<?php echo $liste['lien1']; ?></a></th>
<th><?php echo $liste['autre']?></th>
</tr>
<?php
}
?>

The $nompage fonction is ->

$nompage = htmlspecialchars($_GET["nom"]);
$nompage = mysql_real_escape_string($nompage);

I can see 4 row, because I have 4 items in my tables.

This is the error I get on the second and third column.

Notice: Undefined index: lien1 in C:\xampp\htdocs\show.php on line 102
Notice: Undefined index: autre in C:\xampp\htdocs\show.php on line 103
  • 写回答

3条回答 默认 最新

  • doutang6600 2014-12-08 12:52
    关注

    The query should be -

    'SELECT * FROM '.$nompage.' ORDER BY id' // if $nompage contains the table name
    

    And avoid using mysql. It is deprecated. Try to use mysqli or PDO.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入