[英]How do I query a mysql database for a file in php and then send the response?
I would like to have the PHP look up a document in a mysql table and then send out an http response.我想让 PHP 在 mysql 表中查找文档,然后发送 http 响应。 The response will later be used in a iPad app.该响应稍后将在 iPad 应用程序中使用。 the only response I get from this PHP to my app is: <>我从这个 PHP 对我的应用程序的唯一响应是:<>
Not helpful... Any ideas?没有帮助...有什么想法吗? Thanks so much!非常感谢!
<?
$username=$_GET['user'];
$password=$_GET['secret'];
$database="db";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die("Unable to select database");
$sql = "SELECT * FROM documents WHERE documentId='2'";
$result = mysql_query($sql);
dataT = @mysql_result($result, 0, "Document");
$name = @mysql_result($result, 0, "DocumentTitle");
$size = @mysql_result($result, 0, "DocumentSize");
$type = @mysql_result($result, 0, "DocumentType");
header("Content-type: $type");
header("Content-length: $size");
header("Content-Disposition: attachment; filename=$name");
header("Content-Description: PHP Generated Data");
header("Content-transfer-encoding: binary");
echo $dataT;
mysql_close();
?>
There is a $ in front of前面有个$
dataT = @mysql_result($result, 0, "Document");
missing.失踪。
Please activate all error reportings, ie E_NOTICE
- then you would see such errors yourself and early.请激活所有错误报告,即E_NOTICE
- 然后您将自己和及早看到此类错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.