简体   繁体   English

我的php代码在localhost上有效,但在实际服务器上不起作用

[英]My php code works on localhost, but doesn't work on the actual server

This is probably a pretty basic question...but I'm trying to create a basic php survey in Eclipse with xampp that inputs data into a database. 这可能是一个非常基本的问题...但是我正在尝试使用xampp在Eclipse中创建一个基本的php调查,该调查将数据输入到数据库中。 It works just fine on the localhost, but whenever I upload it to the website using Filezilla, it just displays the PHP text. 它在localhost上可以正常工作,但是每当我使用Filezilla将其上传到网站时,它只会显示PHP文本。

What I tried then to do is create the database and the table on the actual website (the code of which works perfectly on localhost), but I get a "The page cannot be found" error (the website is www.digitalcowboyrepair.com and the link I entered was www.digitalcowboyrepair/createdatabase.php" Here's the code 然后,我想做的是在实际网站上创建数据库和表(其代码在localhost上完美运行),但出现“找不到页面”错误(该网站为www.digitalcowboyrepair.com和我输入的链接是www.digitalcowboyrepair / createdatabase.php“这是代码

Createdatabase.php Createdatabase.php

<?php

    ini_set('display_errors',1);
    ini_set('display_startup_erros',1);
    error_reporting(E_ALL);

    $con=mysqli_connect("localhost","root","password");
    // Check connection
    if (mysqli_connect_errno())
    {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }

    // Create database
    $sql="CREATE DATABASE testdb1";
    if (mysqli_query($con,$sql))
    {
        echo "Database testdb1 created successfully";
    }
    else
    {
        echo "Error creating database: " . mysqli_error($con);
    }

?>

Your production server is Server:Microsoft-IIS/6.0 您的生产服务器是Server:Microsoft-IIS/6.0

The instructions for installing PHP on IIS 6 are at http://php.net/manual/en/install.windows.iis6.php 在IIS 6上安装PHP的说明位于http://php.net/manual/en/install.windows.iis6.php

Here are the headers from the Server response: 以下是服务器响应中的标头:

HTTP/1.0 304 Not Modified
Content-Location: http://www.digitalcowboyrepair.com/index.html
Last-Modified: Mon, 15 Jul 2013 17:15:42 GMT
Accept-Ranges: bytes
Server: Microsoft-IIS/6.0
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
Date: Mon, 15 Jul 2013 17:57:35 GMT

If you do not already have MySQL installed on the server, you can find the instructions at http://dev.mysql.com/doc/refman/5.7/en/windows-installation.html 如果您尚未在服务器上安装MySQL ,则可以在http://dev.mysql.com/doc/refman/5.7/en/windows-installation.html上找到说明。

Are you copying the file to the right server path? 您是否正在将文件复制到正确的服务器路径? That may be the cause of the "Page not found" error. 这可能是“找不到页面”错误的原因。 In IIS the default folder is "c:\\inetpub\\wwwroot\\", if not maybe your server has a virtual directory pointing to another filesystem path. 在IIS中,默认文件夹为“ c:\\ inetpub \\ wwwroot \\”,如果不是,则您的服务器具有指向另一个文件系统路径的虚拟目录。

Then you'll be able to execute the file. 然后,您将能够执行文件。 If the server shows PHP source code instead echo messages you'll have to install PHP module for IIS and install the mysql libraries for PHP. 如果服务器显示PHP源代码,而不是回显消息,则必须为IIS安装PHP模块并为PHP安装mysql库。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 php函数在localhost中有效,但在服务器上不起作用 - php function works in localhost but doesn't on the server 强制文件下载代码在本地主机上工作,但在 php 中的实际服务器上不工作 - force file download code work on localhost but not working on actual server in php PHP-提交登录表单后重定向到主页在服务器上不起作用,但在localhost上可以正常工作 - PHP- Redirect to home page after submit login form doesn't work on server but works fine on localhost PHP INSERT 查询不适用于 web 服务器,但适用于 localhost。 没有返回错误 - PHP INSERT query doesn't work on web server but works on localhost. No errors returned js 代码在网络托管上不起作用,但它在本地主机上工作 - js code doesn't work on web hosting but it works on localhost 这个 php 代码在本地主机上工作,但不在服务器上? - this php code works in localhost but not on server? 此代码适用于 php 5.6(服务器状态),为什么它不适用于 php 7.4? - This code works in php 5.6 (server status), why doesn't it work in php 7.4? PHP文件上传脚本在我的服务器上不起作用,但在其他服务器上起作用 - PHP file upload script doesn't work on my server but works on different server PHP代码在Ubuntu服务器中不起作用 - PHP code doesn't work in Ubuntu server PHP登录代码不适用于Web服务器,仅适用于本地 - PHP Login code doesn't work on web server, only works on local
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM