PHP unlink 正在请求一个字符串并试图给它 sql 字符串
我正在尝试从某个文件夹中删除一个项目,并且我需要将该项目的路径传递给 unlink()。由于某种原因,它说我没有返回字符串,我不知道该怎么做。
这是所有代码:
$filePath = "Select path FROM library where id=" .$id;
unlink(mysql_query($filePath));
$library = "DELETE FROM library WHERE id =" .$id;
$files = "DELETE FROM files WHERE library_id=" .$id;
mysql_query($library) or die('Unable to update using sql '.$library.' '.mysql_error($link));
mysql_query($files) or die('Unable to update using sql '.$files.' '.mysql_error($link));
I am trying to delete an item from a folder somewhere, and I need to pass in the path of the item to unlink(). For some reason it says I am not returning a string, which I am not sure how to do.
Here is all the code:
$filePath = "Select path FROM library where id=" .$id;
unlink(mysql_query($filePath));
$library = "DELETE FROM library WHERE id =" .$id;
$files = "DELETE FROM files WHERE library_id=" .$id;
mysql_query($library) or die('Unable to update using sql '.$library.' '.mysql_error($link));
mysql_query($files) or die('Unable to update using sql '.$files.' '.mysql_error($link));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
mysql_query 返回一个语句句柄,而不是一个字符串。您需要从结果中获取一行:
mysql_query returns a statement HANDLE, not a string. You need to fetch a row from the result:
mysql_query
返回资源,而不是字符串。使用:
流程:
$query
)。$result
中。path
列的值。有关详细信息和使用说明,请参阅手册。
mysql_query
returns a resource, not a string.Use:
The process:
$query
).$result
.path
column.See the manual for detailed information and usage notes.
http://php.net/manual/en/function.mysql-query.php
http://www.php.net/manual/en /function.mysql-result.php
mysql_query 实际上并不返回您所选择的查询的值,但返回结果资源。您可以使用函数 mysql_result(, , ) 来获取所需的信息。
http://php.net/manual/en/function.mysql-query.php
http://www.php.net/manual/en/function.mysql-result.php
mysql_query does not actually return the values of that your query selected, but a result resource. You can use the function mysql_result(, , ) to get the wanted information.