dongxu8533486 2016-02-20 19:35
浏览 413
已采纳

HTTP错误405.0 - 不允许的方法

I have a have rented a server at www.unoeuro.com (I dont know if this matters) When i submit the form it gives me "HTTP Error 405.0 - Method Not Allowed"

<?php

define('DB_NAME', '');
define('DB_USER', '');
define('DB_PASSWORD', '');
define('DB_HOST', '')

$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);

if (!$link) {
 die('Could not connect: ' .mysql_error());
}

$db_selected = mysql_slect_db(DB_NAME, $link);

if (!$db_selected) {
 die('Could not connect: ' .mysql_error());
}

$value = $_POST['username'];

$sql = "INSERT INTO test (username) VALUES ('$value')";

if (!mysql_query($sql)) {
 die('Error: ' . mysql_error());
}
mysql_close();
?>
<!doctype HTML>
  <form action="test.php" method="post">
    <p>Username: <input type="text" name="username" /><p>
    <input type="submit" value="Submit" />
  </form>

Can anyone tell me what i am doing wrong? Just ask me for screenshots of anything you can use to help!

Sorry if the issue is obvious. This is my first time working with any kind of database, PHP and such.

Thanks!

</div>
  • 写回答

1条回答 默认 最新

  • donglie1994 2016-02-20 20:11
    关注

    First of all, if those are your actual database username and password, you're going to want to be changing those sharpish before someone else changes them for you :)

    It's most likely down to how your server is configured to handle PHP files.

    The first thing I would check is that the package you are leasing is designed to host PHP scripts. Looking at the UnoEuro package details (https://en.unoeuro.com/products.php#specs) it states 'ASP or PHP'. Is it possible that you are using a server setup for ASP?

    If you are definitely on a PHP package, I would contact the service provider. They should know everything there is to know about configuring your server.

    Also; there is a typo in your code 'mysql_slect_db'.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入