/* 在 $selected m 中从成功存储在 $selected 中的 java 代码中获取数据。在查询中使用 $selected 但在触发查询后无法获取任何数据。 */
$selected = $_GET['selected'];
$projects=mysql_query("select ProjectName from projects where LobID =
( select LobID from lob where LobName like ".$selected.");");
if (!$projects) {
echo "Could not successfully run query ($projects) from DB: " .mysql_error();
exit;
}
/* Have included this query in my php page. All the table names are same.Lob and projects are two different tables n LobID is primary key in Lob & Foreign key in projects. By executing the above query I am not able to fetch the data in $projects.Instead i am getting mesagecould not successfully run query. please help. */
最佳答案
查询应该是这样的
$projects=mysql_query("select ProjectName from projects where LobID =
(select LobID from lob where LobName like '$selected')");
将 ".$selected.");
更改为 '$selected'
关于php - SQL 内部查询不提供输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28935780/