远程网站上的相同PHP代码在本地Apache中不起作用

时间:2012-01-12 22:54:57

标签: php mysql html apache localhost

我正在使用PHP,PHPMyAdmin和MySQL设置Apache。我有 PHP:5.3.0 Apache:2.2.21(Win32) PHPMyAdmin:3.4.9 MySQL:5.5

我浏览了设置PHP的基本指南,但它似乎仍然无法正常工作。我打开了短标签以便修复,但我是Apache的新手,所以我可能错过了一些东西。我的代码在我拥有的Web主机上的远程服务器上工作正常,但在我的本地Apache上却没有。我认为它与我的header.php有关,它是从index.php文件链接的,并链接到header.php.html文件。这是header.php.html文件,我认为问题所在。如果您没有答案,请说明一些规则,以确保Apache可以读取我的文件。

我得到的错误是:致命错误:在第20行的C:\ server \ www \ myserver.dev \ public_html \ luvbid \ themes \ default \ header.php.html中调用未定义的函数MySQLError()< / p>

虽然,如果我只是说“死”而不是“MySQLError”那么我得到“$ query =”select * from BPLA_users where in plain text。

<?
$query = "select * from BPLA_users where     nick='".$_SESSION['BPLowbidAuction_LOGGED_IN_USERNAME']."'";
$result = @mysql_query($query);
$TPL_balance = "00.00";
if(!$result) {
MySQLError($query);
} else {
$USER = mysql_fetch_array($result);
$TPL_balance    = number_format($USER['balance'], 2, '.', '');
}
$is_pre_registration = (isset($_REQUEST['pre_registration']) &&     ($_REQUEST['pre_registration'] == "1")) ? "1" : "";
if ($HTTPS == '1' || $HTTPS == 'on') {
$SITEURL = $Https['httpsurl'];
$SETTINGS['siteurl'] = $Https['httpsurl'];
} else {
$SITEURL = $SETTINGS['siteurl'];
$SETTINGS['siteurl'] = $SETTINGS['siteurl'];
}
?>
<!DOCTYPE HTML>
<html lang="en">
<head>
    <meta name="google-site-verification" content="OXR3zBD_6YDDtqAsOLw6wkb6zqVshFark-S7dMO2zNM" />
    `<? $mobile_browser = '0'; if (preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|android)/i', strtolower($_SERVER['HTTP_USER_AGENT']))) { $mobile_browser++; } if ((strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml') > 0) or ((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))) { $mobile_browser++; } $mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'], 0, 4)); $mobile_agents = array( 'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac', 'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno', 'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-', 'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-', 'newt','noki','oper','palm','pana','pant','phil','play','port','prox', 'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar', 'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-', 'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp', 'wapr','webc','winw','winw','xda ','xda-'); if (in_array($mobile_ua,$mobile_agents)) { $mobile_browser++; } if (strpos(strtolower($_SERVER['ALL_HTTP']),'OperaMini') > 0) { $mobile_browser++; } if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'windows') > 0) { $mobile_browser = 0; } if ($mobile_browser <= 0) { ?>`

<link href="http://www.luvbid.com/css/style.css" type="text/css" rel="stylesheet" />              <script src="http://cdn.jquerytools.org/1.2.6/jquery.tools.min.js"></script>
<link type="text/css" rel="stylesheet"      href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/themes/smoothness/jquery-ui.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-
ui.min.js"></script>
<script src="js/jquery.alerts.js"></script>
<script type="text/javascript">
$(function() {
    jQuery("#dialog-about-help").hide();
        $("#opener-about-help").click(function(event) {
            event.preventDefault();
            jQuery("#liveauctions").toggle();
            $("#dialog-about-help").slideToggle();
        });
    });
</script>
<script type="text/javascript">
$(function() {
        jQuery("#dialog-login").hide();
        $("#opener-login").click(function(event) {
            event.preventDefault();
            jQuery("#liveauctions").toggle();
            $("#dialog-login").slideToggle();
        });
    });
    </script>
    <script>
        $(function() {
            $(".mobileproductbg").remove();
        });

    </script>
    <? } else { ?>
    <link href="http://www.luvbid.com/css/mobilestyle.css" type="text/css" rel="stylesheet" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
    <script type="text/javascript" src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
    <script>
        $('div').bind('pageinit', function() {
            $(this).find('a').bind('click', function(e) {
                e.preventDefault();
            });
        });

    </script>
    <script>
        $(function() {
            $(".productbg").remove();
        });

    </script>
    <? } ?> <title>Luv Bid</title>
    <? if($SETTINGS['descriptiontag'] != '') { print "
    <META name=\"description\" content=\"".stripslashes($SETTINGS['descriptiontag'])."\">"; } if($SETTINGS['keywordstag'] != '') { print " <META name=\"keywords\" content=\"".stripslashes($SETTINGS['keywordstag'])."\">"; } //print " <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' /> "; $main_page = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : "home"; $show = isset($_GET['show']) ? $_GET['show'] : ""; ?>
    <? if ($SETTINGS[currency]=="USD") $SETTINGS[currency]="$"; if ($SETTINGS[currency]=="EUR") $SETTINGS[currency]="&euro;"; ?>
    <? if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start(); ?>
</head>
<body>
    <div data-role="page" data-fullscreen="true">
        <div class="ui-bar-d" data-role="header">
            <img src="http://www.luvbid.com/themes/default/img/logo.png" alt="Luv Bid" class="logo" /><h1 class="logo-text">Luv Bid</h1>
            <a class="mobileheader" data-role="button" data-icon="home" data-iconpos="notext" href="index.php?">Auctions</a>
            <div data-role="navbar">
                <ul id="mobileheader">
                    <li>
                        <a href="#dialog-about-help" data-rel="dialog" id="opener-about-help">About/Help</a>
                    </li>
                    <? if($_SESSION["BPLowbidAuction_LOGGED_IN"]) { ?>
                    <li>
                        <a data-icon="gear" href="user_menu.php">Settings</a>
                    </li>
                    <li>
                        <a href="logout.php">Logout</a>
                    </li>
                    <? } else { ?>
                    <li>
                        <a href="#dialog-login" data-rel="dialog" id="opener-login">Login</a>
                    </li>
                    <? if ($TPL_errmsg != ""){ ?>
                    <li>
                        <?echo $TPL_errmsg?>
                    </li>
                    <? } ?>
                    <li>
                        <a href="register.php">Register</a>
                    </li>
                    <? } ?>
                </ul>
            </div>
        </div>
        <div data-role="content">
            <nav id="header">
                <ul>
                    <li>
                        <a href="index.php?">Auctions</a>
                    </li>
                    <li>
                        <a id="opener-about-help">About/Help</a>
                    </li>
                    <li>
                        <a href="affiliates">Become An Affiliate!</a>
                    </li>
                    <? if($_SESSION["BPLowbidAuction_LOGGED_IN"]) { ?>
                    <li>
                        <a href="user_menu.php">Settings</a>
                    </li>
                    <li>
                        <a href="logout.php">Logout</a>
                    </li>
                    <? } else { ?>
                    <li>
                        <a id="opener-login">Login</a>
                    </li>
                    <? if ($TPL_errmsg != ""){ ?>
                    <li>
                        <?echo $TPL_errmsg?>
                    </li>
                    <? } ?>
                    <li>
                        <a href="register.php">Register</a>
                    </li>
                    <? } ?>
                </ul>
            </nav>
            <div id="dialog-about-help" data-role="dialog" style="text-align:left;">
                <? echo $MSG_33_0036 ?>
            </div>
            <div align="center" data-role="dialog" id="dialog-login">
                <form name="user_login" action="<? echo $Https['httpsurl']?>user_login.php?" method="post">
                    <label for="username"><? print $MSG_187; ?></label>
                    <input type="text" name="username" value="<? echo $TPL_nick; ?>" />
                    <br>
                    <label for="password">Password</label>
                    <input type="password" name="password" value="" />
                    <br>
                    <input type="checkbox" name="rememberme" value="1" />
                    <? echo $MSG_25_0085 ?>
                    <br>
                    <button type="submit" name="" value="<? echo $MSG_052?>"  class="button">
                        <? echo $MSG_052?>
                    </button>
                    <input type="hidden" name="action" value="login" />
                    <br>
                    <a href="forgotpasswd.php"><? print $MSG_215; ?></a>
                </form>
            </div>

1 个答案:

答案 0 :(得分:0)

好的,首先PHP工作正常,我们知道这是因为您收到了错误消息。其次,您正在获取查询的纯文本,因为您可能正在调用die($query),它将简单地退出进程并输出传递的任何内容,在本例中为SQL查询语句。您遇到此问题是因为mysql_query返回false并且您的第一次if()检查表明如果此调用的结果为false,则退出该过程。

PHP正在运行,问题似乎是您的代码中没有有效的数据库连接,或者查询以其他方式失败。除mysql_error之外使用die会更有用,这实际上会为您提供有关错误的信息。此外,您应该从mysql_query中删除错误抑制,我敢打赌我的底部美元会触发错误,告诉您出现了什么问题。