做了一个文章系统的上下条文章,在静态页面显示功能。结果遇到一些问题,导致在本地显示是正常的(可能本地配置要求不是很严谨,所以语法错误也可以显示),但是在服务器无法读出内容。
而且在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
}
?>求帮助,请帖代码。
而且在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
}
?>求帮助,请帖代码。
这样的标记,需要 sxt.php 输出的是没有语法错误的 js 代码
你可以单独执行一下 /sxt.php?id=444&class=xinwen 看看都是些什么?
自己不能看出毛病的话,请贴出
1、你是按 id 升序排列,排在前面的当然是最早的
2、你有 limit 0,1 当然是会有一条结果如果是“本地读取正常”,那么建议你更换你的计算机!都不按指令工作了,那还要他干什么?
{}
……
{
$result=$db->query("select * from news where classid='".$class."' and id>'".$id."' order by id limit 0,1");
}
……
代码的括号没用的太多,不合语法规则。
但都不是楼上各位提到的。在顶部加上
$id=$_GET[id];
$class=$_GET['class'];这个问题就解决了。
结贴。