【问题标题】:PHP request returns at professional hosting service returns "The requested URL / was not found on this server"PHP 请求返回专业托管服务返回“请求的 URL / 未在此服务器上找到”
【发布时间】:2015-09-03 02:37:59
【问题描述】:

我正在通过网络链接和 php 从网络平台 Second Life 将客户信息发送到 SQL 服务器。我的 SQL 服务器由欧洲最大的网络托管公司托管,所以我不认为他们会出错。

我编写了一个非常简单的 PHP 脚本,它可以为数据库转换信息,我已经成功地完成了很多次。这次发生了一个非常意外的错误:当我测试包含变量的 URL 时,我收到以下消息:在此服务器上找不到请求的 URL / ...

这是 PHP 代码:

<?php

//You need to insert your specific data for "DB_HOSTNAME","DB_USERNAME","DB_PASSWORD","DB_DATABASE"

$con=mysqli_connect("DB_HOSTNAME","DB_USERNAME","DB_PASSWORD","DB_DATABASE");
// Check connection
if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

//use the parameters in the http-link to set the $ variables and real escape them for security reasons 

$key = mysqli_real_escape_string($con, $_GET['key']); 
$name = mysqli_real_escape_string($con, $_GET['name']); 
$pass = mysqli_real_escape_string($con, $_GET['pass']); 
$mailinglist = "1"; 

//Insert the $ variables into the table 
$sql="INSERT INTO SAGS_Global_Players (key, name, pass, mailinglist) VALUES ('$key', '$name', '$pass', '$mailinglist')"; 

//for debugging: print out the db query on the screen
//echo $sql . '<br/>'; 

if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } 


//close connection to database
mysqli_close($con); ?>

网址“http://webaddress/8ftgde/newplayer.php&key=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&name=estelle.pie&pass=6fcrV1vZUC&mailinglist=1

给出结果:

找不到

在此服务器上找不到请求的 URL http://webaddress/8ftgde/newplayer.php&key=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&name=estelle.pie&pass=GpTIVOavhc

如果我使用没有变量的相同地址 (= http://webaddress/8ftgde/newplayer.php),则会创建一个新的数据库条目。但是(当然)只输入了自动递增的客户编号和邮件列表的常量变量“1”。

帮助任何人?

【问题讨论】:

  • 添加'?'进入网址。而不是“..../newplayer.php&key=...”使用“.../newplayer.php?key=...”。确保将其余的“&”符号保留在 url 中。
  • 《第二人生》没死?哇。
  • @Scott:天啊,问号……!我很尴尬。谢谢!我需要新眼镜。
  • @Arkascha:SL 每月仍有 700.000 名独立用户,而创意人士去年通过向其他客户出售他们的虚拟产品总共获得了 6000 万美元的收入。还不错吧?

标签: php mysqli


【解决方案1】:

如果有任何更改导致此错误,请检查您的 .htaccess 文件

【讨论】:

    【解决方案2】:

    我将 Scott 的评论作为答案。如果你想自己做,斯科特,那么我会用最佳答案标记它。我犯了最愚蠢的错误:我忘记在链接中的变量前放一个问号。真丢人!

    【讨论】:

      猜你喜欢
      • 2018-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-30
      • 2016-12-29
      • 2014-05-18
      相关资源
      最近更新 更多