<?php被切断之后的所有内容[复制]

This question already has an answer here:

im setting up a new mysql/php server, im trying to pull data from the mysql db but everything after the <?php tag is cutoff

ive tried putting test html, <p>test</p> above the php and after, only the test html above html was displayed

<?php
mysql_connect("localhost","root","");
mysql_select_db("pet");
$sql = mysql_query("SELECT * FROM pet");
$name = 'name';
$owner = 'owner';
$species = 'species';
$sex = 'sex';
$birth = 'birth';
$death = 'death';
$rows = mysql_fetch_assoc($sql);
echo 'Name: ' . $rows[$id] . '<br>' . 'Owner: ' . $rows[$owner] . '<br>' . 'Species: ' . $rows[$species] . '<br>' . 'Sex: ' . $rows[$sex] . '<br>' . 'Birthday: ' . $rows[$birth];
?>

i expected the table to be displayed, but the output was just the above mentioned "test" from <p>test</p> at the top, nothing else

edit: forgive me, this is my first post and im new to sql and php

</div>

Have you looked through the error logs?

Errors and warnings usually appear in ....\logs\php_error.log or ....\logs\apache_error.log depending on your php.ini settings.

But what I think is happening here is that your PHP is crashing when it tries to parse $row[$id] since you haven't yet initialized $id.

you have an error in your code ! if you are using a new version of PHP you must use mysqli instead of mysql you can see the exact error in php error log