为什么我的PHP没有显示任何东西? (代码包括在内)

为什么我的PHP没有显示任何东西?  (代码包括在内)

问题描述:

This code should give a table of the table cats. However, it shows a blank page. It seems the query part does not work. It cannot go to 'var_dump($results)'. However, I can create a table using codes having been commented. So what is the problem ?

<?php
require_once "login.php";
$db_server = mysql_connect($db_hostname, $db_username, $db_password);
if(!$db_server)
    die("Unable to connect: ".mysql_error());
mysql_select_db($db_database, $db_server) or die("Unable to select a db: ".mysql_error());
/*
$query = "CREATE TABLE cats
(
    id SMALLINT NOT NULL AUTO_INCREMENT,
    family VARCHAR(32) NOT NULL,
    name VARCHAR(32) NOT NULL,
    age TINYINT NOT NULL,
    PRIMARY KEY (id)
)";

mysql_query($query) or die("Create cats DB failed: ".mysql_error());
*/

$query = "DESCRIBE cats";
$results = mysql_query($query)

var_dump($results);

if(!$results)
    die("Error-line22: ".mysql_error());
else 
    echo $results."<br />";

$rows = mysql_num_rows($results);

echo "<table>";
echo "
<tr> <th>Column</th> <th>Type</th> <th>NULL</th> <th>Key</th> </tr>";

for ($j = 0; $j < $rows; ++$j)
{
    $row = mysql_fetch_row($results);
    echo "<tr>";
    for ($k = 0; $k < 4; ++$k)
        echo "<td>$row[$k]</td>";
    echo "</tr>";
}

echo "</table>";

mysql_close($db_server);
?>

此代码应该提供表格的表格。 但是,它显示一个空白页面。 似乎查询部分不起作用。 它不能转到' var_dump($ results) code>'。 但是,我可以使用已注释的代码创建表。 那么问题是什么? p>

 &lt;?php 
require_once“login.php”; 
 $ db_server = mysql_connect($ db_hostname,$ db_username,$ db_password); 
if(!$ db_server)  
 die(“无法连接:”。mysql_error()); 
mysql_select_db($ db_database,$ db_server)或die(“无法选择数据库:”。mysql_error()); 
 / * 
 $ query  =“CREATE TABLE cats 
(
 id SMALLINT NOT NULL AUTO_INCREMENT,
 family VARCHAR(32)NOT NULL,
 name VARCHAR(32)NOT NULL,
 age TINYINT NOT NULL,
 PRIMARY KEY(id)  
)“; 
 
mysql_query($ query)或die(”Create cats DB failed:“。mysql_error()); 
 * / 
 
 $ query =”DESCRIBE cats“; 
 $ results =  mysql_query($ query)
 
var_dump($ results); 
 
if(!$ results)
 die(“Error-line22:”。mysql_error()); 
else 
 echo $ results。“&lt;  br /&gt;“; 
 
 $ rows = mysql_num_rows($ results); 
 
echo”&lt; table&gt;“; 
echo”
&lt; tr&gt;&lt; th&gt; Column&lt; / th&gt;&lt; th&gt;  ;键入&lt; / th&gt;&lt; th&gt; NULL&lt; / th&gt;&lt; th&gt;键&lt; / th&gt;&lt; / tr&gt;“; 
 
for($ j = 0; $ j&lt; $ rows; ++  $ j)
 {
 $ row = mysql_  fetch_row($ results); 
 echo“&lt; tr&gt;”; 
 for($ k = 0;  $ k&lt;  4;  ++ $ k)
 echo“&lt; td&gt; $ row [$ k]&lt; / td&gt;”; 
 echo“&lt; / tr&gt;”; 
} 
 
echo“&lt; / table&gt;  “; 
 
mysql_close($ db_server); 
?&gt; 
  code>  pre> 
  div>

The mysql_query() line is missing a ';' at the end:

$query = "DESCRIBE cats";
$results = mysql_query($query);

var_dump($results);