php - 查询在 mysqlyog 查询窗口中有效,但在 php 脚本中无效?

标签 php mysql

我从中选择了两个表 1 我想获取用户信息, 2 我想获取属于该用户的所有图像。但查询不检索图像,但在查询窗口中我得到了它们。同样在脚本中,如果我决定从图像表中选择,则会显示图像,但是当我进行连接时,它不起作用。我知道有些事情做得不好。请任何帮助将不胜感激 下面是代码

$query='SELECT 
tish_clientinfo.lastname, tish_clientinfo.address,
tish_clientinfo.firstname,
tish_images.image_name
  FROM  tish_clientinfo 
  INNER JOIN tish_images 
ON tish_clientinfo.user_id = tish_images.user_id
 WHERE user_id= '. intval($_GET['user_id']);
$result = $con->prepare($query);
$result->execute();

最佳答案

可能是服务器混淆了 user_id。试试这个

$query='SELECT 
tish_clientinfo.lastname, tish_clientinfo.address,
tish_clientinfo.firstname,
tish_images.image_name
  FROM  tish_clientinfo 
  INNER JOIN tish_images 
ON tish_clientinfo.user_id = tish_images.user_id
 WHERE tish_clientinfo.user_id= '. intval($_GET['user_id']);

关于php - 查询在 mysqlyog 查询窗口中有效,但在 php 脚本中无效?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15083820/

相关文章:

php - MYSQL三元数据库选择

php - composer update 给出关于私有(private)存储库元数据的 404

php - 使用外键和多对一连接三个表

php - 如何在 Ubuntu 14.04 上卸载 LAMP?

php - Nginx connect() 失败错误

java - OSGI中的JDBC驱动程序问题

php - 如何着手修改 Wordpress "Pages Add New Screen"

mysql - MySQL中使用保留字作为表名或列名导致的语法错误

php - 多公司 Web 应用程序数据库安全

mysql - 估计 MySQL 查询运行时间