我在as4上安装了mysql和php-mysql
rpm -qa | grep php-mysql
php-mysql-4.3.9-3.22.4rpm -qa | grep MySQL
MySQL-shared-4.1.20-0
MySQL-devel-standard-4.1.20-0.rhel4
MySQL-client-4.1.20-0
MySQL-server-standard-4.1.20-0.rhel4可是在浏览器打开web测试页面时空白,具体测试php文件如下:
more testconnectmysql.php
<?php
$link=mysql_connect('localhost','root','123456'); 
if(!$link) echo "失败!"; 
else echo "成功!"; 
mysql_close(); 
?> 而打开其他php文件正常,如
more test.php
<?
phpinfo();
?>请问该如何解决,谢谢。

解决方案 »

  1.   

    是不是php-mysql还要配置啥东西呢?
      

  2.   

    补充一句php-mysql和mysql都是rpm安装的
      

  3.   

    可是在浏览器打开web测试页面时空白
    -----------------------------
    是因为你的代码有问题 而php.ini的默认配置 不会输出错误
    修改/etc/php.ini(你php的配置文件) 把设置Error handling and logging这个域里追加
    error_reporting  =  E_ALL 
    默认的error_reporting都是被注释掉的 然后重启httpd 这样就可以看看你输出的是什么错误了! 另外 你在命令行下用命令 mysql  -hlocalhost -uroot -p 的方式能访问mysql吗
      

  4.   

     ./mysql -u root -p
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 11 to server version: 4.1.20-standardType 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql> 
    可以访问sql的。
      

  5.   

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ; Error handling and logging ;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; error_reporting is a bit-field.  Or each number up to get desired error
    ; reporting level
    ; E_ALL             - All errors and warnings
    ; E_ERROR           - fatal run-time errors
    ; E_WARNING         - run-time warnings (non-fatal errors)
    ; E_PARSE           - compile-time parse errors
    ; E_NOTICE          - run-time notices (these are warnings which often result
    ;                     from a bug in your code, but it's possible that it was
    ;                     intentional (e.g., using an uninitialized variable and
    ;                     relying on the fact it's automatically initialized to an
    ;                     empty string)
    ; E_CORE_ERROR      - fatal errors that occur during PHP's initial startup
    ; E_CORE_WARNING    - warnings (non-fatal errors) that occur during PHP's
    ;                     initial startup
    ; E_COMPILE_ERROR   - fatal compile-time errors
    ; E_COMPILE_WARNING - compile-time warnings (non-fatal errors)
    ; E_USER_ERROR      - user-generated error message
    ; E_USER_WARNING    - user-generated warning message
    ; E_USER_NOTICE     - user-generated notice message
    ;
    ; Examples:
    ;
    ;   - Show all errors, except for notices
    ;
    ;error_reporting = E_ALL & ~E_NOTICE
    ;
    ;   - Show only errors
    ;
    ;error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR
    ;
    ;   - Show all errors
    ;
    error_reporting  =  E_ALL
    我看了php.ini配置error_reporting  =  E_ALL这个是有的呢。