简单的MYSQL数据不显示致命错误 [英] Simple MYSQL data not displaying Fatal Error

查看:90
本文介绍了简单的MYSQL数据不显示致命错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从html数据中显示mysql数据的数据,并观看了视频,并跟随他们改变只需要什么是像表名称数据库名称等。
我一直收到这个错误?

I am trying to display data from a mysql data in a html data and have watched videos and followed them changing only what is necessary like table names DB names etc. I keep getting this error?

解析错误:语法错误,意外的'$ sql'(T_VARIABLE)在C:\ xampp\htdocs\keytracker\keytracker.php第37行

Parse error: syntax error, unexpected '$sql' (T_VARIABLE) in C:\xampp\htdocs\keytracker\keytracker.php on line 37

   <html>
<head>
<title>SRE | Key Tracker</title>
<link rel = "stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="searchandregister">
<h2 class="cat-title">Search Booked Keys</h2>
<form method="POST" action="">
<input class="field" type="text" placeholder="Key ID" onfocus="this.placeholder=''" onblur="this.placeholder='Key ID'">
<input class="field" type="text" placeholder="Property Address" onfocus="this.placeholder=''" onblur="this.placeholder='Property Address'">
<input class="field" type="text" placeholder="Name" onfocus="this.placeholder=''" onblur="this.placeholder='Name'">
<input class="field" type="text" placeholder="Creditor" onfocus="this.placeholder=''" onblur="this.placeholder='Creditor'">
<br/><input class="button" type="submit" value="Search">
</form><br/>


<h2 class="cat-title">Book Out New Key</h2>
<form method="POST" action="">
<input class="field" type="text" placeholder="Key ID" onfocus="this.placeholder=''" onblur="this.placeholder='Key ID'">
<input class="field" type="text" placeholder="Property Address" onfocus="this.placeholder=''" onblur="this.placeholder='Property Address'">
<input class="field" type="text" placeholder="Name" onfocus="this.placeholder=''" onblur="this.placeholder='Name'">
<input class="field" type="text" placeholder="Creditor" onfocus="this.placeholder=''" onblur="this.placeholder='Creditor'">
<br/><input class="button" type="submit" value="Register">
</form>

</div>

<div class="results">
<h2 class="cat-title-right">Results</h2>
<?php
    //Make connection
        mysql_connect('localhost', 'access', 'AR51Bigwater');
    //Select DB
        mysql_select_db('keytracker')

    $sql="SELECT * FROM keys";
    $records = mysql_query($sql);
    //Display Data

?>
<table cellpadding="1" cellspacing="1">
<tr>

<th>ID</th>
<th>Name</th>
<th>Company</th>
<th>Out_Date</th>
<th>Due_Date</th>
<tr>

<?php
while ($keys=mysql_fetch_assoc($records)){
    echo "<tr>";
    echo "<td>".$keys['ID']."</td>";
    echo "<td>".$keys['Name']."</td>";
    echo "<td>".$keys['Company']."</td>";
    echo "<td>".$keys['Out_Date']."</td>";
    echo "<td>".$keys['Due_Date']."</td>";
    echo "</tr>";
}   
?>
</table>
</div>

这是根据错误发生错误的部分:

This is the section where the error occurs as per the error:

 <?php
    //Make connection
        mysql_connect('localhost', 'access', 'AR51Bigwater');
    //Select DB
        mysql_select_db('keytracker')

    $sql="SELECT * FROM keys";
    $records = mysql_query($sql);
    //Display Data

?>


推荐答案

错误清楚地说明<强>你错过了第36行中的分号,如@HoboSapiens所说。

The error clearly states syntax error you missed the semicolon in line 36 as said by @HoboSapiens .

请注意:您应该使用 MySQLi / PDO_MySQL ,而不是的mysql。整个ext / mysql PHP扩展从PHP v5.5.0正式被弃用,并将在将来删除。

Note: You should use MySQLi / PDO_MySQL, instead of mysql. The entire ext/mysql PHP extension is officially deprecated as of PHP v5.5.0 and will be removed in the future.

您可以从这里 a>。

<?php
    //Make connection
    $connection = mysqli_connect('localhost', 'access', 'AR51Bigwater','keytracker');

    $sql="SELECT * FROM keys";
    $records = mysqli_query($connection,$sql);
    //Display Data

?>

这篇关于简单的MYSQL数据不显示致命错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆