PHP不会显示echo的结果

时间:2017-03-27 19:40:19

标签: php html mysql

我有一个问题,当我尝试使用此代码而没有托管我得到了结果但是当我在主机上尝试它时php不会显示结果,我知道现在选择*不好但是如果你可以请求帮助。

这是屏幕的样子:

这是代码:

$conn = mysql_connect("localhost", "username", "password");
   if (!$conn) {
die("no connection".mysql_error());
}

$db = mysql_select_db("db_name");
 mysql_set_charset('utf8', $conn);

我在HTML上使用此代码:

          <thead> 
          <tr>
            <th>id</th>
            <th>სახელი</th>
            <th>ტექსტი</th>
            <th>პატარა ტექსტი</th>
            <th>სურათი</th>
            <th>წაშლა</th>
          </tr>
       </thead> 
       <tbody>
            <?php
            $sql = "SELECT * FROM news";
            $result = mysql_query($sql);
            while ($data = mysql_fetch_array($result)){
              echo "<tr>";
              echo "<td>".$data['id']."</td>";
              echo "<td>".$data['name']."</td>";
              echo "<td>".substr($data['article'], 155,300)."</td>";
              echo "<td>".substr($data['text'], 155)."</td>";
              echo "<td>".$data['img']."</td>";
              echo "<td><a href='del.php?id=".$data['id']."' onClick=\"javascript:return confirm('ნამდვილად გსურს წაშლა?');\">წაშლა</a></td>";
              echo "</tr>";} 
            ?>
   </tbody>

0 个答案:

没有答案