0

我有一个 MYSQL 表,其中有一列定义为 TEXT,当我将内容读入 PHP 时,结果是数据没有被拉过。

我的PHP代码

SELECT establishments.name AS estName, 
            establishments.address AS estAddr,
            establishments.telephone_num AS estTel,
            establishments.description AS estDesc,
            establishments.Logo AS estLogo,
            establishments.title AS estTitle
      FROM bucurestideals1.establishments
      WHERE establishments.establishment_id ="'.$est_id.'"';

表格行有数据,所以这不是问题,我正在使用 php 读取数据,如下所示:

    $.ajax({
    type: 'GET',
    url: pass_url,
    dataType: 'jsonp',
    jsonp: 'jsoncallback',
    timeout: 5000,
    success: function (data, status) {

        // Assign the returned data to the page
        $.each(data, function(i,item)
        {


          alert(item.estDesc);



        });

    },

更新:PHP代码

<?php

  header('Content-type: application/json');
  $est_id = $_GET['id'];
  $server = "*";
  $username = "*";
  $password = "*";
  $database = "";
  $con = mysql_connect($server, $username, $password) or die ("Could not connect: " . mysql_error());
  mysql_select_db($database, $con);
  $result = mysql_query($sql) or die ("Query error: " . mysql_error());
  $records = array();
  while($row = mysql_fetch_assoc($result))
  {
     $records[] = $row;
  }
  mysql_close($con);
  echo $_GET['jsoncallback'] . '(' . json_encode($records) . ');';
  ?>
4

1 回答 1

0

您可能可以从 where 语句中删除引号。如果那不是问题,您可以发布用于执行 sql 的 php 代码吗?

于 2013-04-26T21:10:35.207 回答