-3

PHPを使用してmysqlデータベースからデータを取得し、そのデータをhtml Webページに書き込もうとしています。しかし、私が見るのは空白で、何も書かれておらず、間違いがどこにあるかを見つけることができません。localhost phpMyadmin のパスワードを変更したので、間違いはありません。「データベースに接続できません」というエラーも発生しません。

これが私のコードです:

   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Kaç Yakıyor?</title>
<style type="text/css">
body
{
    background-color:#CCC;
}
h1.header
{
    font-family:"Courier New", Courier, monospace;
    font-size:45px;
    font-style:oblique;
    font-weight:400;
    text-align:center;
}
div.content
{
    margin-top:100px;
    margin-left:auto;
    margin-right:auto;
    width:61%;
    background-color:#F00;
}
div.vehicles
{
    margin-top:100px;
    width:17%;
    height:200px;
    background-color:#0F6;
    float:left;
}
</style>
</head>
<body>

<?php
mysql_connect("localhost","root","123123") or die(mysql_error());
mysql_select_db("kacyakiyor") or die(mysql_error());
$query = "SELECT marka from arabalar";
$result = mysql_query($query);

if($result){
    while($row = mysql_fetch_array($result)){
?>
        <h1 class="header">KAÇ YAKIYOR</h1>
        <hr width="500px"/>
        <div class="vehicles">
        <h2><strong><em>Araba</em></strong></h2><hr/><br/>
        <?php echo "$row['marka']"; ?>
        <h2><strong><em>Motosiklet</em></strong></h2><hr/><br/></div>
        <div class="content">asdfasfda
        </div>
<?php
    }
}
mysql_close();
?>
</body>
</html>
4

3 に答える 3