[英]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.