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条)

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据