dragon87836215 2015-07-07 03:45
浏览 72

使用php和mysql的500内部服务器错误[重复]

So my website keeps giving me a 500 Internal Server Error when I attempt to open my PHP file to write to the MySQL database

HTML

<div id="body">
<form action="index.php" method="post" />
  <input type="text" name="usertext" />
  <input type="submit" value="Submit" />
 </form>
</div>

PHP

<?php

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

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

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

$db_selected = mysqli_select_db(DB_NAME, $link);

if (!$db_selected) {
    die('Cannot access' . DB_NAME . ': ' . mysqli_error());
}

$value = $_POST['****'];

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

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

mysqli_close();
?>

I'm still new to HTML and PHP, but I can't figure out what I did wrong even after hours of searching. My website keeps giving me that same error. I use goDaddy as a host if that helps at all.

</div>
  • 写回答

3条回答 默认 最新

  • duanliao5995 2015-07-07 04:06
    关注

    Most 500 errors are server-side errors.

    There can be following probable reasons :

    1. Permission Error : Check permission of files and folders. In most of those cases, an incorrect permission on a PHP and CGI script is to blame. The permission should be set at 755.
    2. PHP Timeout : Timeout rules, or better error handling in your script, should help if this is the cause of the 500 error.
    3. Error in .htaccess : Check if .htaccess is structured properly.
    评论

报告相同问题?

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值