连字符在php数据库表名中

时间:2014-08-27 12:38:13

标签: php mysql

我遇到了与这个家伙完全相同的问题:mysqli php table names with hyphen or space但我并不完全理解它,因为它的代码太多了。有人可以看看我的代码并告诉我在代码中我需要更改什么来解决问题:

<form action="dienstencheque_dienstencheques_huishoudhulp_poetsvrouw_kuisvrouw_.php" method="get">
<?php
extract($_GET);
mysql_connect("localhost", "phpgebruiker", "php");
mysql_select_db("poetsco");
$gemeente = "SELECT naam FROM $provincie ORDER BY naam ASC";
$resultaat = mysql_query($gemeente) or die("FOUT" . mysql_errno() . ": " . mysql_error());
$rij = mysql_fetch_array($resultaat);
  while ($rij) { ?>
   <a href="dienstencheque_dienstencheques_huishoudhulp_poetsvrouw_kuisvrouw_.php?gemeente=<?php print $rij["naam"] ?>"> Huishoudhulp in <?php print $rij["naam"] ?></a><br>
<?php $rij = mysql_fetch_array($resultaat);} ?>
</form>

1 个答案:

答案 0 :(得分:0)

如果$provincie中定义的表名包含连字符,则必须在SQL查询中引用它:

$gemeente = "SELECT naam FROM `$provincie` ORDER BY naam ASC";