<?php
$db=mysql_connect("localhost","root","123456");
mysql_select_db("news",$db);
?>
<?php
$res = mysql_query("select * from news where id={$id}");
$row = mysql_fetch_array($res);
$title = $row["title"]; //标题
$date = $row["date"]; //时间
$content = $row["content"]; //内容
?><!--新闻标题-->
<table width="778" border="1" align="center">
<tr><td><b><?php echo $title; ?>aaaaaa</b></td></tr>
</table><hr width="778" align="center"><table width="778" border="1" align="center">
<tr><td align="center">发布时间:<?php echo $date; ?></td></tr>
</table><br><!--正文-->
<table width="778" border="1" align="center" valign="top">
<tr><td> <?php echo $content; ?>bbbbbb</td></tr>
</table>
$db=mysql_connect("localhost","root","123456");
mysql_select_db("news",$db);
?>
<?php
$res = mysql_query("select * from news where id={$id}");
$row = mysql_fetch_array($res);
$title = $row["title"]; //标题
$date = $row["date"]; //时间
$content = $row["content"]; //内容
?><!--新闻标题-->
<table width="778" border="1" align="center">
<tr><td><b><?php echo $title; ?>aaaaaa</b></td></tr>
</table><hr width="778" align="center"><table width="778" border="1" align="center">
<tr><td align="center">发布时间:<?php echo $date; ?></td></tr>
</table><br><!--正文-->
<table width="778" border="1" align="center" valign="top">
<tr><td> <?php echo $content; ?>bbbbbb</td></tr>
</table>
$res =mysql_query("select * from news where id = $id");
或:$res =mysql_query("select * from news where id = $id");
仍报错:
Parse error: syntax error, unexpected T_VARIABLE in D:\PHPnow\htdocs\kjbzixun\neirong.php on line 7
或:$res =mysql_query("select * from news where id = ".$id."");
改为:$res =mysql_query("select * from news where id = ".$id.""); //后面两个引号
改为:$res =mysql_query("select * from news where id = ".$id.""); 报8行错
Parse error: syntax error, unexpected T_VARIABLE in D:\PHPnow\htdocs\kjbzixun\neirong.php on line 8
$db=mysql_connect("localhost","root","123456");
mysql_select_db("news",$db);
?>
<?php
$res =mysql_query("select * from news where id = ".$id."");
$row = mysql_fetch_array($res); //第8行
$title = $row["title"]; //标题
$pubtime = $row["pubtime"]; //时间
$content = $row["content"]; //内容
?><!--新闻标题-->
<table width="778" border="1" align="center">
<tr><td><b><?php echo $title; ?>aaaaaa</b></td></tr>
</table><hr width="778" align="center"><table width="778" border="1" align="center">
<tr><td align="center">发布时间:<?php echo $pubtime; ?></td></tr>
</table><br><!--正文-->
<table width="778" border="1" align="center" valign="top">
<tr><td> <?php echo $content; ?>bbbbbb</td></tr>
</table>
$res = mysql_query("select * from news where id={$id}");1
$row = mysql_fetch_array($res); 2
$title = $row["title"]; //标题 3
$date = $row["date"]; //时间 4
$content = $row["content"]; //内容 5
?>
自己可以慢慢调试错误!在1和2或3和4之间插入echo mysql_error()
如果还没有找到,再在每两行之间输入类似于echo "aaaaa";查看具体是哪一行出错!!
$title = $row["title"]; //标题
$pubtime = $row["pubtime"]; //时间
$content = $row["content"]; //内容 在这一行$row = mysql_fetch_array($res);的前后用echo mysql_error(); 查看错误!
$db=mysql_connect("localhost","root","ztw888888");
mysql_select_db("news",$db);
?>
<?php
$res =mysql_query("select * from news where id = ".$id."");
echo mysql_error(); //8行
$row = mysql_fetch_array($res);
echo mysql_error();
?>显示Parse error: syntax error, unexpected T_ECHO in D:\PHPnow\htdocs\kjbzixun\neirong.php on line 8
记得我以前表中的字段是一些常用的单词,结果提示错误。找了好久错误都没有找到,最后偶然改了一下字段名
没想到可以了!!
不知道是不是可以同名!自己多改改!最好不用news作为表名
我觉得如果是int这样就可以了