0
我无法运行我的代码。使用PHP连接MYSQL
它说:
语法错误,意外 '$查询'(T_VARIABLE)。
代码
<?php
$hostname="localhost";
$username="";
$password="";
$dbname="thesis";
$usertable="product";
$yourfield="product_id";
msql_connect($hostname,$username,$password) or die ("<html><script>
language='Javascript'>alert('Unable to connect to database!.'),history.go(-1)</script></html>")
$query = "SELECT * FROM $usertable";
$result = mysql_query($query);
if($result)
{
while ($row = mysql_fetch_array($result))
{
$name = $row["$yourfield"];
echo "Name: ".$name."</br>";
}
}
?>