dtnpzghys01643322 2010-01-06 15:01
浏览 28

Apache和PHP的问题(使用PEAR)

I have a problem with Apache, which restarting, when I want to open PHP code in browser. Code :

require_once 'DB.php';
PEAR::setErrorHandling(PEAR_ERROR_DIE);

$db_host = 'localhost';
$db_user = 'root';
$db_pass = 'marylover';
$db_name = 'test';
$dsn = "mysql://$db_user:$db_pass@unix+$db_host/$db_name";
$db = DB::connect($dsn);

It's crashing on the last line -> cannot connect to MySQL, I think. I want to use PEAR and Apache, but it seems they don't like each other. Help me, please! Thanks.

  • 写回答

1条回答 默认 最新

  • dongque5529 2010-01-06 16:26
    关注

    When you say:

    It's crashing on the last line -> cannot connect to MySQL, I think. I want to use PEAR and Apache, but it seems they don't like each other. Help me, please! Thanks.

    I'm assuming you mean at the PHP level (ie your script quits, there is no "crash" at the webserver level)?

    The build of PHP being used with Apache is most likely going to be different to what you're using with your IDE (phpDesigner). The mysql extension in the PHP build being used with Apache could be trying to connect to MySQL differently (for example via a socket file that does not exist).

    Unless I've misunderstood, it would seem the script is exiting because it can't connect to the database server.

    This line looks like it would cause this to happen:

    PEAR::setErrorHandling(PEAR_ERROR_DIE);
    

    You should try running some sample code to see if the error lies with establishing a connection to MySQL:

    <?php
    error_reporting(E_ALL);
    ini_set('display_errors', 1);
    $conn = mysql_connect('localhost', 'root', 'marylover');
    mysql_select_db('test', $conn);
    

    Also check your configure command via phpinfo() and see if either of your PHP build's has been compiled with the --with-mysql-sock option

    评论

报告相同问题?

悬赏问题

  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来