简体   繁体   English

如何在 mysql 数据库中查询 php 中的文件,然后发送响应?

[英]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.

相关问题 我如何将字符串从AS3发送到PHP文件,以便可以用来执行数据库查询 - How can i send a String from AS3 to a PHP file so it can be use to do a database query 如何使用 PHP 在 mysql 数据库中导入 a.sql 文件? - How do I import a .sql file in mysql database using PHP? 如何在HTML表格中创建一个按钮以使PHP执行MySQL数据库查询而无需单独的js文件? - How do I create a button inside an HTML table to make PHP execute a MySQL database query without needing a seperate js file? 我如何使用jquery ajax在同一个文件中发送多个请求并在php中获取所需的响应 - How do i send multiple requests for the same file and get the required response back in php using jquery ajax 如何使用PHP将HTML文档中的文本区域数据发送到MySQL数据库? - How do I use PHP to send text area data from an HTML document to MySQL database? 如何在Wordpress中将表单字段值发送到PHP mysql查询? - How do I send form field values to a php mysql query in wordpress? 如何在php中选择mysql数据库? - How do I select mysql database in php? 在PHP中,如何从mysql数据库中检索文件并作为附件发送到电子邮件中? - In PHP how can I retrieve file from mysql database and send as attachment in email? 如何将PHP变量数组发送到MySQL数据库? - How can I send a PHP variable array to a MySQL database? 在一个process.php文件中提交第二次查询之前,如何查询SQL数据库? - How do I query an SQL database to before submitting second query in one process.php file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM