本机是win7 系统  
php版本:PHP Version 5.2.6 
apache 2.2
mysql:5.1.40本地测试,PHP可以正常   但是唯一的就是不能连接上mysql  也不能使用phpmyadmin  本地测试在IE下直接就是错误页, 在360 下会提示一个:您指定的网页无法访问!  错误类型:连接失败请高手帮解决,重谢...

解决方案 »

  1.   

    你连接MYSQL的语句发出来看一下吧。
      

  2.   

    <?php
    $link=mysql_connect('localhost','root','admin');
    if(!$link) 
      echo "fail";
    else 
      echo "success";
    mysql_close();
    ?>
      

  3.   

    先打开服务,看看你的mysql的服务是否已经启动了下载个Navicat建立鏈接测试一下
    主机名或ip你填写:localhost
    端口:3306
    用户名和密码根据你的设置填写,默认用户名是:root
      

  4.   

    去服务里查看mysql已启动我用的是EMS SQL MANAGER 2005 lite for mysql  是可以连上数据库的, 
    用的是localhost  
    端口3306
    用户名root
    密码admin这个是可以连接上数据库的。  
      

  5.   

    求解,为什么PHP就连接不上mysql呢
    自己顶一下。
      

  6.   

    <?php
    $link=mysql_connect('localhost','root','admin');
    if(!$link) echo "fail".mysql_error(); //看看输出什么错误信息
    else echo "success";
    ?>
      

  7.   

    <?php
    $link=mysql_connect('localhost','root','admin');
    if(!$link) echo "fail".mysql_error(); //看看输出什么错误信息
    else echo "success";
    ?>
      

  8.   

    换上<?php
    $link=mysql_connect('localhost','root','admin');
    if(!$link) echo "fail".mysql_error(); //看看输出什么错误信息
    else echo "success";
    ?>
    后,运行此程序段出现Internet Explorer 无法显示该网页
      

  9.   

    你用我的代码连接一下试试
    $Conn=mysql_connect("localhost","root","admin",1) Or Die('Database server connection failed, check the Config configuration is correct!');或$pdo = New PDO('mysql:host=localhost;dbname=数据表名称','root','admin');
      

  10.   

    我粘上无法显示该网页的代码<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
     
        <head>
            <link rel="stylesheet" type="text/css" href="ErrorPageTemplate.css" >
     
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>Internet Explorer 无法显示该网页</title>
     
            <script src="errorPageStrings.js" language="javascript" type="text/javascript">
            </script>
            <script src="httpErrorPagesScripts.js" language="javascript" type="text/javascript">
            </script>
        </head>
     
        <body onLoad="javascript:initMoreInfo('infoBlockID');">
     
            <table width="730" cellpadding="0" cellspacing="0" border="0">
     
            <!-- Error title -->
                <tr>
                    <td id="infoIconAlign" width="60" align="left" valign="top" rowspan="2">
                        <img src="noConnect.png" id="infoIcon" alt="信息图标" width="48" height="48">
                    </td>
                    <td id="mainTitleAlign" valign="middle" align="left" width="*">
                        <h1 id="mainTitle">Internet Explorer 无法显示该网页</h1>
                    </td>
                </tr>
     
                <tr>
                    <!-- This row is for HTTP status code, as well as the divider-->
                    <td id="errorCodeAlign" class="errorCodeAndDivider" align="right">&nbsp;
                        <div class="divider"></div>
                    </td>
                </tr>
     
            <!-- What you can do -->
                <tr>
                    <td>
                        &nbsp;
                    </td>
                    <td id="whatToTryAlign" valign="top" align="left">
                        <h2 id="whatToTry">您可以尝试以下操作:</h2>
                    </td>
                </tr>
     
            <!-- Check Connection -->
                <tr>
                    <td >
                        &nbsp;
                    </td>
                    <td id="checkConnectionAlign" align="left" valign="middle">
                        <h4>
                            <table>
                                <tr>
                                    <td valign="top">
                                    </td>
                                    <td valign="middle">
                                        <button onclick="javascript:diagnoseConnectionAndRefresh(); return false;" id="diagnose">诊断连接问题</button>
                                    </td>
                                </tr>
                            </table>
                        </h4>
                    </td>
                </tr>
     
     
            <!-- InfoBlock -->
                <tr>
                    <td id="infoBlockAlign" align="right" valign="top">
                        &nbsp;
                    </td>
                    <td id="moreInformationAlign" align="left" valign="middle">
                        <h4>
                          <table>
                              <tr>
                                  <td valign="top">
                                      <a href="#" onclick="javascript:expandCollapse('infoBlockID', true); return false;"><img src="down.png" id="infoBlockIDImage" border="0" class="actionIcon" alt="详细信息"></a>
                                  </td>
                                  <td valign="top">
                                      <span id="moreInfoContainer"></span>
                                      <noscript><ID id="moreInformation">更多信息</ID></noscript>
                                  </td>
                              </tr>
                          </table>
                        </h4>
                        <div id="infoBlockID" class="infoBlock" style="display: none">
                            <p>
                                <ID id="errorExpl1">此问题可能是由下列各种问题导致的:</ID>
                                <ul>
                                    <li id="errorExpl2">Internet 连接已丢失。</li>
                                    <li id="errorExpl3">该网站暂时不可用。</li>
                                    <li id="errorExpl4">无法连接到域名服务器(DNS)。</li>
                                    <li id="errorExpl5">域名服务器(DNS)没有该网站的域的列表。</li>
                                    <li id="errorExpl7">在地址中可能存在键入错误。</li> 
                                    <li id="errorExpl6">如果这是 HTTPS (安全)地址,请单击“工具”菜单下的“Internet 选项”,再单击“高级”选项卡,然后请检查以确保“安全”部分下的 SSL 和 TLS 协议已启用。</li>
                                </ul>
                            </p>
                            <p id="offlineUsers">对于脱机用户<b></b></p>                                     
                            <p id="viewSubscribedFeeds1">
                               仍可查看已订阅的源和最近查看过的一些网页。<br/>
                               若要查看已订阅的源
                               <ol>
                                   <li id="viewSubscribedFeeds2">单击“收藏夹”按钮<img src="favcenter.png" border="0">,单击“源”,然后单击希望查看的源。</li>
                               </ol>
                            </p>
                            <p id="viewRecentWebpages1">查看最近访问过的网页(不查看所有页面)
                               <ol>
                                  <li id="viewRecentWebpages2">单击“工具”<img src="tools.png" border="0">,然后单击“脱机工作”。</li>
                                  <li id="viewRecentWebpages3">单击“收藏夹”按钮<img src="favcenter.png" border="0">,单击“历史记录”,然后单击希望查看的页面。</li>
                               </ol>
                            </p>
                        </div>
                    </td>
                </tr>
     
            </table>
     
        </body>
    </html>
    ry
      

  11.   

    404错误,访问的文件不存在,或者你输入的URL不对。
      

  12.   


     页面一点开就运行中....  然后就出现该问题。。   该页面下跟mysql无关的都可以运行。 我访问phpmyadmin 这个也是,可以进入到登陆页面,输入用户名与密码后,就会运行...然后出现该页面,无法显示
    php能运行。 就是不能访问mysql....... 要怎么搭。。 根据网上的php.ini这个文件已经有过n次更改了,一直访问不了
      

  13.   

    你只需开启php的错误显示功能,就什么都知道了
      

  14.   

    实在不行你就下载集成环境吧
    http://www.php100.com/html/download/server/2010/1226/wamp21a.html
    简单实用,不用配置ini就行.我也在用这个
      

  15.   


    php.ini已配置着显示错误呢。 就是不显示,不知道原因在哪块谢谢了,我想先弄明白这一块,毕竟要使用PHP了,弄不明白心里不太舒服
      

  16.   

    本帖最后由 xuzuning 于 2011-05-30 16:26:38 编辑
      

  17.   


    写成你这样,网页显示空白,查看源码也无任何信息。。开启错误功能我更改的是如下:;error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR
    ;
    ;   - Show all errors except for notices and coding standards warnings
    ;
    error_reporting  =  E_ALL & ~E_NOTICE
    ; Print out errors (as a part of the output).  For production web sites,
    ; you're strongly encouraged to turn this feature off, and use error logging
    ; instead (see below).  Keeping display_errors enabled on a production web site
    ; may reveal security information to end users, such as file paths on your Web
    ; server, your database schema or other information.
    ;
    ; possible values for display_errors:
    ;
    ; Off        - Do not display any errors
    ; stderr     - Display errors to STDERR (affects only CGI/CLI binaries!)
    ;
    ;display_errors = "stderr"
    ;
    ; stdout (On) - Display errors to STDOUT
    ;
    display_errors =On
      

  18.   

    上面的本想加红。结果成代码。。;error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR
    ;
    ;   - Show all errors except for notices and coding standards warnings
    ;
    error_reporting  =  E_ALL & ~E_NOTICE; Print out errors (as a part of the output).  For production web sites,
    ; you're strongly encouraged to turn this feature off, and use error logging
    ; instead (see below).  Keeping display_errors enabled on a production web site
    ; may reveal security information to end users, such as file paths on your Web
    ; server, your database schema or other information.
    ;
    ; possible values for display_errors:
    ;
    ; Off        - Do not display any errors
    ; stderr     - Display errors to STDERR (affects only CGI/CLI binaries!)
    ;
    ;display_errors = "stderr"
    ;
    ; stdout (On) - Display errors to STDOUT
    ;
    display_errors =On
      

  19.   

    display_startup_errors = On试试。
      

  20.   

    你需要在 phpinfo() 的结果页面中查看 display_errors 项
      

  21.   

    <?php
    $dbbase="localhost";
    $dbname="root";
    $dbpass="1234";
    $id=mysql_connect($dbbase,$dbname,$dbpass);
    $ok=mysql_select_db("lvyou",$id);
    mysql_query('SET names "utf8"');
    ?>这个是我常用的 修改测试一下  一般不会有问题。
      

  22.   

    对,用此方法输出一下看看php的状况
      

  23.   

        把地址栏的http://localhost/访问MYSQL的PHP页地址改换为:http://127.0.0.1/访问MYSQL的PHP页地址
    或者颠倒过来试一下!
      

  24.   

    根据以上几楼改动测试。问题依旧未解决我粘上我的phpinfo()页面的一些结果上来Configuration
    PHP Core
    Directive Local Value Master Value 
    allow_call_time_pass_reference On On 
    allow_url_fopen On On 
    allow_url_include Off Off 
    always_populate_raw_post_data Off Off 
    arg_separator.input & & 
    arg_separator.output & & 
    asp_tags Off Off 
    auto_append_file no value no value 
    auto_globals_jit On On 
    auto_prepend_file no value no value 
    browscap no value no value 
    default_charset no value no value 
    default_mimetype text/html text/html 
    define_syslog_variables Off Off 
    disable_classes no value no value 
    disable_functions no value no value 
    display_errors On On 
    display_startup_errors On On 
    doc_root no value no value 
    docref_ext no value no value 
    docref_root no value no value 
    enable_dl On On 
    error_append_string no value no value 
    error_log no value no value 
    error_prepend_string no value no value 
    error_reporting 6135 6135 
    expose_php On On 
    extension_dir c:\php\ext c:\php\ext 
    file_uploads On On 
    highlight.bg #FFFFFF #FFFFFF 
    highlight.comment #FF8000 #FF8000 
    highlight.default #0000BB #0000BB 
    highlight.html #000000 #000000 
    highlight.keyword #007700 #007700 
    highlight.string #DD0000 #DD0000 
    html_errors Off Off 
    ignore_repeated_errors Off Off 
    ignore_repeated_source Off Off 
    ignore_user_abort Off Off 
    implicit_flush Off Off 
    include_path .;C:\php5\pear .;C:\php5\pear 
    log_errors Off Off 
    log_errors_max_len 1024 1024 
    magic_quotes_gpc On On 
    magic_quotes_runtime Off Off 
    magic_quotes_sybase Off Off 
    mail.force_extra_parameters no value no value 
    max_execution_time 30 30 
    max_input_nesting_level 64 64 
    max_input_time 60 60 
    memory_limit 2M 2M 
    open_basedir no value no value 
    output_buffering no value no value 
    output_handler no value no value 
    post_max_size 8M 8M 
    precision 12 12 
    realpath_cache_size 16K 16K 
    realpath_cache_ttl 120 120 
    register_argc_argv On On 
    register_globals Off Off 
    register_long_arrays On On 
    report_memleaks On On 
    report_zend_debug On On 
    safe_mode Off Off 
    safe_mode_exec_dir no value no value 
    safe_mode_gid Off Off 
    safe_mode_include_dir no value no value 
    sendmail_from no value no value 
    sendmail_path no value no value 
    serialize_precision 100 100 
    short_open_tag On On 
    SMTP localhost localhost 
    smtp_port 25 25 
    sql.safe_mode Off Off 
    track_errors Off Off 
    unserialize_callback_func no value no value 
    upload_max_filesize 2 2 
    upload_tmp_dir no value no value 
    user_dir no value no value 
    variables_order EGPCS EGPCS 
    xmlrpc_error_number 0 0 
    xmlrpc_errors Off Off 
    y2k_compliance On On 
    zend.ze1_compatibility_mode Off Off 
      

  25.   

    重新安装php 和apache 到其他非c盘看看.包括mysql.
    没必要在这种事情上纠结.
      

  26.   

    这种情况很简单,只需要把 php.ini中“;extension=php_mysql.dll”前的“;”去掉,加载mysql模块。重要的是配置Apache把其中的httpd.conf 中加入“ phpinidir “E:/PHP””就是你的安装路径
      

  27.   

    在IE的选项里把友好的HTTP错误信息那个勾去掉。
      

  28.   

    呵呵,很简单的问题么。php链接不上mysql 大都是php.ini 中dll 文件没有开启.phpinfo 看下就知道有没有链接上。LZ 啊 多学习啊
      

  29.   


    这个在前几楼已经做答,能打开的都打开了, phpinfo我已经贴出来了  连接数据库的dll全开了
    这个问题在前几楼也已经提过了。不是这么简单吧, 这些象你说的,我全都是做过的。
      

  30.   

    首先检查你的php的配置文件是不是都配置好了,有没有漏掉的
    然后检查mysql的服务开启了没
    按照mysql的过程中,有没有设置错误
    阿帕奇有没有设置成功
      

  31.   


    经检查需要的都配置好了PHP 程序可以通过阿帕奇 运行       这个说明 PHP运行环境没有问题mysql服务已启动, 并且可以连接使用, 唯一不行的就是 PHP 不能连接 mysql 
      

  32.   

    apache/logs/error.log
    看一下,能不能发现问题
      

  33.   

    C:\php\ext  加入环境变量  php
      

  34.   

    先测试下数据库是否正常运行吧,两个办法:
    1.命令行下运行telnet localhost 3306 看看能连上不?
    2.命令行下进入到mysql安装目录下的bin目录,运行 mysql -u root -p 然后输入你的root用户密码,如果能连上说明mysql运行正常。除了以上检查,你还可以看看apache的日志
      

  35.   

    libmysql.dll 是PHP里面的而不是MYSQL里面的拷贝到System32
      

  36.   

    1.extension_dir = ".\ext"
    2.php的目录要加到环境变量 path ,目的是引用那个mysqllib.dll的东西。
    3.extension=php_mysql.dll 注析去掉
    4.display_errors = On 方便调式,最好打开,不然就只有404错误,看到undefine function就是前面的问题。要是apache能访问一般php页,数据库也应该能连。记得改完以上设置后,一定要重启apache,就行了。用phpinfo能看到mysql模块存在(我的操作系统不需要重启)。
      

  37.   

    是否是8080端口被占用呢,不要用"localhost",用127.0.0.1试试?
      

  38.   

    是不是win7系统?如果是win7系统$link=mysql_connect('localhost','root','admin');改成
    $link=mysql_connect('127.0.0.1','root','admin');