日期:2014-05-17  浏览次数:20500 次

一个传递值的问题
做了一个文章系统的上下条文章,在静态页面显示功能。结果遇到一些问题,导致在本地显示是正常的(可能本地配置要求不是很严谨,所以语法错误也可以显示),但是在服务器无法读出内容。
而且在Dreamweaver里,总是提示第四行包含一个错误语法,即<?php 这个有语法问题?


静态页面的代码是:

<script language='javascript' type='text/javascript' src='/sxt.php?id=444&class=xinwen'></script>


sxt.php的代码:

<?php
include('conn.php');
?>
<?php
if($_GET['id']=="");

($_GET['class']=="");
{}
$result=$db->query("select * from news where classid='".$class."' and id<'".$id."' order by id desc limit 1");

while($row=$db->getarray($result)){
?>
document.write("<p><a href='<?php echo $row[path]; ?>'><?php echo $row[title]; ?></a></p>");
<?php
}
?>


<?php 
{
$result=$db->query("select * from news where classid='".$class."' and id>'".$id."' order by id limit 0,1");
}
while($row=$db->getarray($result))
{
?>
document.write("<p><a href='<?php echo $row[path]; ?>'><?php echo $row[title]; ?></a></p>");
<?php
}
?>





求帮助,请帖代码。




------解决方案--------------------
<script language='javascript' type='text/javascript' src='/sxt.php?id=444&class=xinwen'></script>
这样的标记,需要 sxt.php 输出的是没有语法错误的 js 代码
你可以单独执行一下 /sxt.php?id=444&class=xinwen 看看都是些什么?
自己不能看出毛病的话,请贴出
------解决方案--------------------
你要贴出你js请求的url的结果数据啊。不知怎么知道你php输出什么导致了js报错。

探讨

本地读取正常。
服务器只读取最早的数据内容。即ID=1的内容
而且只读1条

------解决方案--------------------
这是什么玩意???
PHP code
if($_GET['id']=="");

($_GET['class']=="");

------解决方案--------------------
($_GET['class']=="");
{}
……

{
$result=$db->query("select * from news where classid='".$class."' and id>'".$id."' order by id limit 0,1");
}
……
代码的括号没用的太多,不合语法规则。
------解决方案--------------------
说的对,代码看起来有点乱啊!
探讨

($_GET['class']=="");
{}
……

{
$result=$db->query("select * from news where classid='".$class."' and id>'".$id."' order by id limit 0,1");
}
……
代码的括号没用的太多,不合语法规则。