dongnei3634 2011-04-29 20:10
浏览 51
已采纳

如何知道在localhost上为Apache正确设置PHP?

I am trying to retrieve data from MySQL for a flash application via PHP, but I am having trouble connecting to the server. I created the following .php to test whether it is functioning correctly:

<html>
<body>

<?php
$link = mysql_connect('localhost', 'root', 'password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';

if (mysql_query("CREATE DATABASE testphp",$link))
  {
  echo "Database created";
  }
else
  {
  echo "Error creating database: " . mysql_error();
  }
?>

</body>
</html>

When I try and access this from my browser I don't get anything back, it just remains blank? (when I just do localhost/xxx.php is just displays the code, don't know if that's helpful? -aside from entering file path) I tried some other .php files, but I either just get an error back or white web browser screen, as above? How can I test to see whether PHP is setup correctly? I know for sure it is working when I login using the mysql shell and do "show databases;" and testphp is listed, it is currently not. Thanks!

SOLUTION:

Turns out that I had been using the installer while I think there were a lot of assumptions that I was using binaries (or vice versa). Anyhow I have it up and running...expletive, expletive! :) Thanks everyone!

  • 写回答

2条回答 默认 最新

  • douxian4323 2011-04-29 20:23
    关注

    put the following script somewhere within your document root. Then go to that address it should print out a lot of useful information.

    <?php
      phpinfo();
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码