这个是test.php <?php
$db_host = "127.0.0.1";
$db_username = "root";
$db_password = "";
$db_database = "student";
$db = mysql_connect($db_host, $db_username, $db_password) or die(‘无法连接’.$host.‘Mysql服务’);
mysql_query("SET NAMES ‘UTF8′"); //说明数据库字符集
mysql_select_db($db_database, $db)or die(‘无法连接’.$db_database.‘数据库’);
$sql = "SELECT * FROM class;";
$result = mysql_query($sql)or die($sql.‘出错’);
while($row=mysql_fetch_assoc($result)){
echo"<a href='introduction.php?id="
.$row['id']."'>"
.$row['name']." "
.$row['age']." "
.$row['introduction']
."</a>"."<br/>";
}
?>这个是introduction.php <?php header(‘content-Type=text/html;charset=utf-8′) ?>
<?php
echo "hehe";
$db_host = "127.0.0.1";
$db_username = "root";
$db_password = "";
$db_database = "student";
$db = mysql_connect($db_host, $db_username, $db_password) or die(‘无法连接’.$host.‘Mysql服务’);
mysql_query("SET NAMES ‘UTF8′"); //说明数据库字符集
mysql_select_db($db_database, $db)or die(‘无法连接’.$db_database.‘数据库’);
$theid = $_GET['id'];
$sql = "SELECT * FROM class WHERE id = ".$theid.";";
$result = mysql_query($sql) or die($sql.‘出错’);
$row = mysql_fetch_assoc($result);
echo $row['name'] . "<br/>";
echo $row['age'] . "<br/>";
echo $row['introduction'] . "<br/>";
?>
test.php的内容可以正确显示,而点击超链接时,转到introduction?id=1这个也没错,可就是没有任何显示。
$db_host = "127.0.0.1";
$db_username = "root";
$db_password = "";
$db_database = "student";
$db = mysql_connect($db_host, $db_username, $db_password) or die(‘无法连接’.$host.‘Mysql服务’);
mysql_query("SET NAMES ‘UTF8′"); //说明数据库字符集
mysql_select_db($db_database, $db)or die(‘无法连接’.$db_database.‘数据库’);
$sql = "SELECT * FROM class;";
$result = mysql_query($sql)or die($sql.‘出错’);
while($row=mysql_fetch_assoc($result)){
echo"<a href='introduction.php?id="
.$row['id']."'>"
.$row['name']." "
.$row['age']." "
.$row['introduction']
."</a>"."<br/>";
}
?>这个是introduction.php <?php header(‘content-Type=text/html;charset=utf-8′) ?>
<?php
echo "hehe";
$db_host = "127.0.0.1";
$db_username = "root";
$db_password = "";
$db_database = "student";
$db = mysql_connect($db_host, $db_username, $db_password) or die(‘无法连接’.$host.‘Mysql服务’);
mysql_query("SET NAMES ‘UTF8′"); //说明数据库字符集
mysql_select_db($db_database, $db)or die(‘无法连接’.$db_database.‘数据库’);
$theid = $_GET['id'];
$sql = "SELECT * FROM class WHERE id = ".$theid.";";
$result = mysql_query($sql) or die($sql.‘出错’);
$row = mysql_fetch_assoc($result);
echo $row['name'] . "<br/>";
echo $row['age'] . "<br/>";
echo $row['introduction'] . "<br/>";
?>
test.php的内容可以正确显示,而点击超链接时,转到introduction?id=1这个也没错,可就是没有任何显示。
header('Content-type: text/html; charset=utf-8');//分号
<?php
header('content-Type=text/html;charset=utf-8');//这句的最后面的′和前面的'不匹配
echo "hehe";
$db_host = "127.0.0.1";
$db_username = "root";
$db_password = "";
$db_database = "student";
$db = mysql_connect($db_host, $db_username, $db_password) or die('无法连接'.$host.'Mysql服务');
mysql_query("SET NAMES 'UTF8'"); //说明数据库字符集
mysql_select_db($db_database, $db)or die('无法连接'.$db_database.'数据库');
$theid = $_GET['id'];
$sql = "SELECT * FROM class WHERE id = ".$theid.";";
$result = mysql_query($sql) or die($sql.'出错');
row = mysql_fetch_assoc($result);
echo $row['name'] . "<br/>";
echo $row['age'] . "<br/>";
echo $row['introduction'] . "<br/>";
?>
还是不行,我又试了下 <? phpinfo(); ?> 这个居然也没有显示,可是test.php就可以显示,不知道为什么?
我也测试了下,我这边没有什么问题
你introduction.php
<?php header(‘content-Type=text/html;charset=utf-8′) ?> //这里的前面header(‘ 确实有问题改成如下:<?php header('Content-type:text/html;charset=utf-8');?> 还有一个地方是多余的$sql = "SELECT * FROM class WHERE id = ".$theid.";";$sql = "SELECT * FROM class WHERE id = ".$theid;
很无奈的我发现一个严重的问题,我这里除了test.php能够正常出结果,我不管写多么简单的程序都没有结果,就是个简单的hello world的html页面都不显示,title都不显示。不知道什么地方出问题了。
我刚刚改了下权限,现在有错误提示了 ,可能前面都是这个问题吧
提示: SELECT * FROM class WHERE id=; '出错'