网页不显示php [关闭](Webpage not displaying php [closed])

编程入门 行业动态 更新时间:2024-10-24 17:32:06
网页不显示php [关闭](Webpage not displaying php [closed])

我有一个昨天工作的网页。 这是一个非常基本的页面,里面有一个非常简单的php表。 但是我今天尝试添加另一个列,现在页面将不会加载它甚至在我检查网页元素时都不显示代码。 当我将index.php重命名为index.html时会显示,但当然php表不起作用。 任何帮助,将不胜感激。 此外,我尝试了一个不同的index.php页面,它的工作原理

这是我的PHP:

<?php $servername = "ip"; $username = "username"; $password = "password"; $dbname = "Prices"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT * FROM `prices` ORDER BY `prices`.`Name` ASC"; $result = $conn->query($sql); if ($result->num_rows > 0) { echo "<table><tr><th>Name</th><th>Price In $||</th><th>Price in Ref</th><th>Quantity</th></tr>"; // output data of each row while($row = $result->fetch_assoc()) { echo "<tr><td>" . $row["Name"]. "</td><td>" . $row["Price"]. "</td><td>" . $row["Price_in_Metal"]. "</td><td>" . $row ["Quantity"]"</td></tr>"; } echo "</table>"; } else { echo "0 results"; } $conn->close(); ?>

I have a webpage that was working yesterday. It is a very basic page that has a very simple php table in it. However i attempted to add another column today and now the page won't load it doesn't even show the code when i inspect the element of the webpage. It will display when I rename the index.php to index.html but then of course the php table doesn't work. Any help would be appreciated. Also I tried a different index.php page and it worked

Here is my php:

<?php $servername = "ip"; $username = "username"; $password = "password"; $dbname = "Prices"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT * FROM `prices` ORDER BY `prices`.`Name` ASC"; $result = $conn->query($sql); if ($result->num_rows > 0) { echo "<table><tr><th>Name</th><th>Price In $||</th><th>Price in Ref</th><th>Quantity</th></tr>"; // output data of each row while($row = $result->fetch_assoc()) { echo "<tr><td>" . $row["Name"]. "</td><td>" . $row["Price"]. "</td><td>" . $row["Price_in_Metal"]. "</td><td>" . $row ["Quantity"]"</td></tr>"; } echo "</table>"; } else { echo "0 results"; } $conn->close(); ?>

最满意答案

您没有在循环中连接字符串:

$row ["Quantity"]"</td></tr>";

应该

$row ["Quantity"] . "</td></tr>";

要在将来跟踪这些错误,请参阅: 如何显示PHP错误?

You aren't concatenating a string in the loop:

$row ["Quantity"]"</td></tr>";

Should be

$row ["Quantity"] . "</td></tr>";

For tracking down these errors in the future see: How do I get PHP errors to display?

更多推荐

php,index,echo,page,电脑培训,计算机培训,IT培训"/> <meta name="descripti

本文发布于:2023-07-05 01:09:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1031264.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网页   php   Webpage   displaying   closed

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!