1

php と mysql の接続を試みています。接続は成功しましたが、データを受信して​​いません。ご意見をお聞かせください

また、mysqlとphpを使用しています

The Connection is Successful but nogetting the data into website

enter code here`Please let me know who to correct it<html>
<head>
<title> Welcome to PDM</title>
</head>
<body>
<div>
<centre>
Good For Checking The Prices
</centre>
<?php>` 


    $db_host = "localhost";
    $db_username = "wikiacwj_price";
    $db_pass = "";
    $db_name = "wikiacwj_price";

    mysql_connect("$db_host","$db_username","$db_pass") or die ("Please Try Again");
    mysql_select_db("wikiacwj_price") or die ("no data");

    $sql = mysql_query("SELECT * FROM price_comparsion where product_name='ok'");

    //write the results

    while ($row = mysql_fetch_array($sql)); {
    echo $row['product_name'];}

    ?>
    </body>
    </html>
4

1 に答える 1

2

while ステートメントの直後のセミコロンは、while ループに実行するよう指示します ... 何もしません :)

...
while ($row = mysql_fetch_array($sql)) {
  echo $row['product_name'];
}
...

トリックを行う必要があります。

于 2012-04-21T21:22:06.783 に答える