douxie5176 2018-12-23 05:13
浏览 27

<?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>
  • 写回答

2条回答 默认 最新

  • douzi4766 2018-12-23 05:25
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集
  • ¥15 在启动roslaunch时出现如下问题
  • ¥15 汇编语言实现加减法计算器的功能
  • ¥20 关于多单片机模块化的一些问题
  • ¥30 seata使用出现报错,其他服务找不到seata
  • ¥35 引用csv数据文件(4列1800行),通过高斯-赛德尔法拟合曲线,在选取(每五十点取1点)数据,求该数据点的曲率中心。
  • ¥20 程序只发送0X01,串口助手显示不正确,配置看了没有问题115200-8-1-no,如何解决?
  • ¥15 Google speech command 数据集获取
  • ¥15 vue3+element-plus页面崩溃