涉足另一个“程序员”的世界PHP/MySQL 代码
好吧,我得到了这段有问题的代码:
<!-- Begin the Product Group Submenu -->
<ul>
<?php do { ?>
<li><a href="prodgrouppg.php?groupid=<?php echo $row_menugroup['GroupID']; ?>&groupname=<?php echo $row_menugroup['GroupName']; ?>"><?php echo $row_menugroup['GroupName']; ?></a>
<!-- Retrieve the individual products related to the Group -->
<?php
$groupprod_menuprod = "-1";
if (isset($row_menugroup['GroupID'])) {
$groupprod_menuprod = (get_magic_quotes_gpc()) ? $row_menugroup['GroupID'] : addslashes($row_menugroup['GroupID']);
}
mysql_select_db($database_conn_atex, $conn_atex);
$query_menuprod = sprintf("SELECT products.ProductID, products.ProductName, products.ProductGroup FROM products WHERE products.ProductGroup=%s ORDER BY products.ProductName", GetSQLValueString($groupprod_menuprod, "int"));
$menuprod = mysql_query($query_menuprod, $conn_atex) or die(mysql_error());
$row_menuprod = mysql_fetch_assoc($menuprod);
$totalRows_menuprod = mysql_num_rows($menuprod);
?>
<!-- Begin the product submenu (final menu) -->
<ul>
<? $row_menuprod = mysql_fetch_assoc($menuprod))
{
echo
<li>
<a href="productpg.php?prodid=<?php echo $row_menuprod['ProductID']; ?>">
<? echo $row_menuprod['ProductName']; ?>
</a>
</li>
</ul> <!-- end of Product Submenu -->
</li>
<?php } while ($row_menugroup = mysql_fetch_assoc($menugroup)); ?>
</ul> <!-- end of Group Submenu -->
</li>
<?php } while ($row_menusubcat = mysql_fetch_assoc($menusubcat)); ?>
</ul> <!--end of Subcategory Submenu-->
</li> <!--end of Category Submenu-->
<?php } while ($row_menupaging = mysql_fetch_assoc($menupaging)); ?>
</ul> <!--end of Menu -->
它基本上突然停止工作了。如果我删除此代码,则对该文件的要求会顺利进行,因此我假设此处存在问题。我已经尝试重新格式化大约 5 次了,所以我想一定是我的眼睛漏掉了一些东西。
有什么建议吗?对此代码的状态表示歉意..尝试一次更好地修复它..
Ok so I've got this piece of offending code:
<!-- Begin the Product Group Submenu -->
<ul>
<?php do { ?>
<li><a href="prodgrouppg.php?groupid=<?php echo $row_menugroup['GroupID']; ?>&groupname=<?php echo $row_menugroup['GroupName']; ?>"><?php echo $row_menugroup['GroupName']; ?></a>
<!-- Retrieve the individual products related to the Group -->
<?php
$groupprod_menuprod = "-1";
if (isset($row_menugroup['GroupID'])) {
$groupprod_menuprod = (get_magic_quotes_gpc()) ? $row_menugroup['GroupID'] : addslashes($row_menugroup['GroupID']);
}
mysql_select_db($database_conn_atex, $conn_atex);
$query_menuprod = sprintf("SELECT products.ProductID, products.ProductName, products.ProductGroup FROM products WHERE products.ProductGroup=%s ORDER BY products.ProductName", GetSQLValueString($groupprod_menuprod, "int"));
$menuprod = mysql_query($query_menuprod, $conn_atex) or die(mysql_error());
$row_menuprod = mysql_fetch_assoc($menuprod);
$totalRows_menuprod = mysql_num_rows($menuprod);
?>
<!-- Begin the product submenu (final menu) -->
<ul>
<? $row_menuprod = mysql_fetch_assoc($menuprod))
{
echo
<li>
<a href="productpg.php?prodid=<?php echo $row_menuprod['ProductID']; ?>">
<? echo $row_menuprod['ProductName']; ?>
</a>
</li>
</ul> <!-- end of Product Submenu -->
</li>
<?php } while ($row_menugroup = mysql_fetch_assoc($menugroup)); ?>
</ul> <!-- end of Group Submenu -->
</li>
<?php } while ($row_menusubcat = mysql_fetch_assoc($menusubcat)); ?>
</ul> <!--end of Subcategory Submenu-->
</li> <!--end of Category Submenu-->
<?php } while ($row_menupaging = mysql_fetch_assoc($menupaging)); ?>
</ul> <!--end of Menu -->
Which basically just stopped working out of nowhere. If I delete this code, require for this file goes through OK so I'm assuming something in here is the problem. I've tried reformatting this about 5 times already so I think there must be something my eye is missing.
Any suggestions? Apologies for the state of this code.. trying to fix it up nicer one piece at a time..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定这是复制/粘贴错误还是实际问题,但看起来 PHP 打开了,然后切换到常规 HTML 而不关闭 PHP 块。 (我可能没有使用正确的术语;我不是 PHP 开发人员 - 我只在智选假日酒店住过一次 :p)
通过使用 ASP/VBScript,我发现迁移一个不断切换的页面,并且从代码/html 到直接代码可以帮助发现一些奇怪的事情,例如忘记关闭块或找到收紧循环的方法。
Not sure if this was a copy/paste error, or the actual issue, but it looks like there's a PHP open, then a switch to regular HTML without closing the PHP block. (I may not be using the right terms; I'm not a PHP developer - I just stayed at a Holiday Inn Express once :p )
From working with ASP/VBScript, I've found that migrating a page that keeps switching in and out of code/html to straight code can help find the little oddities like forgetting to close out a block or finding a way to tighten up a loop.