duanjing2013 2014-04-14 08:08
浏览 403
已采纳

GET方法返回500内部服务器错误

I'm new here so I have some question. I'm developing a web site, but there is some problem. I have map with tags, that onclick invokes a function "getObject(this.alt)".

function getObjects(object){
console.log(object);
$.get("/sites/map/objects.php?t="+object, function(data) {
  $('#answer').html(data);
});

It executes script object.php were t= area tags alt attribute, the objects.php connects to MySql and returns objects row, but I get this kind of error:

GET http://some-site.com/sites/map/objects.php?t=some_object 500 (Internal Server Error) jquery-latest.js:8706

Can you please help me? :)

This is the PHP code. Object is alt atribute from area tag in HTML file. It gets this alt and from that returns DB row with this alt name.

<?php
$object = $_GET['t'];
echo $object;
$con=mysqli_connect("server_adr","username","password","db_name");
// Check connection
if (mysqli_connect_errno())
{
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$con->set_charset("utf8");
if($object!='all'){
$result = mysqli_query($con,"SELECT * FROM map WHERE `city`='$object' ORDER BY tips");
}
else{
$result = mysqli_query($con,"SELECT * FROM map ORDER BY tips"); 
}
$old_tips = '';
$old_city = ''; 
while($row = mysqli_fetch_array($result))
  {
  $tips = $row['tips'];
  $city = $row['city'];
  if($old_tips!=$tips){
      echo '<strong>'.$tips.'</strong><br>';
  }
  if($old_city!=$city){
      echo $row['city'] . '<br>';
  }
  echo $row['title'] . ' - <a href="'.$row['web'].'">' . $row['web']. '</a>';
  echo "<br>";
  $old_tips = $row['tips'];
  $old_city = $row['city'];
  }
?>

And the WEB server info:

  • Apache/2.2.21 (FreeBSD) mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2 PHP/5.3.8 with Suhosin-Patch SVN/1.7.1
  • MySQL client version: 5.1.59
  • PHP extension: mysql
  • 写回答

3条回答 默认 最新

  • dougui5419 2014-04-14 09:38
    关注

    mysqli_connect throws exception if mysqli module not installed or enabled. You'd activate this module in the php extions file

    OR if your database is a mysql database and not mysqli, try to change from mysqli to mysql in your php code file

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体