PHP Web服务响应问题

时间:2013-06-02 11:27:06

标签: php web-services

我在php中创建了一个返回JSON的Web服务。它工作正常,但它大多数时候都不一致,它会提取所需的所有信息,除非它遗漏了一个特定的列,这是名为table_bio的倒数第二个表。我认为这是一个缓存问题,但是我在apache和服务中放入了相关的标题,但仍然没有运气。事情是服务正在获取正确的信息,但没有返回正确的信息。

以下是我的代码:

<?php
 error_reporting (E_ALL ^ E_NOTICE);
 $id = $_GET['Table'];
 /* grab the posts from the db */
 $query = "SELECT * FROM table WHERE table_id='$id'";
 $result = mysql_query($query,$link) or die('Errant query:  '.$query);

 /* create one master array of the records */
 while($post = mysql_fetch_assoc($result)) {    $posts = $post;       } 
 /* output in necessary format */
 header('Cache-Control: no-cache, no-store, must-revalidate'); // HTTP 1.1.
 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
 header('Pragma: no-cache'); // HTTP 1.0.
 header('Expires: 0'); // Proxies.
 header('Content-type: application/json');
 echo $_GET['onJSONPLoad'];
 echo "(" . json_encode($posts) . ")";
 @mysql_close($link);
 ?>

有关为何发生这种情况的任何想法?

我还应该提到没有显示的列有时是文本类型

0 个答案:

没有答案
相关问题