duanqiongchong0354 2011-07-28 19:42
浏览 27

查询在phpmyadmin中工作,但不在页面上

I have tried all kinds of things and spent hours doing this and would really like it if someone can tell me what I'm doing.

This is my SQL query: SELECT * FROM txp_file WHERE filename LIKE '%Fast®%' OR description LIKE '%Fast®%'

In phpmyadmin, this brings back the results I want. On the page, the query apparently works but gets no result. I have tried to use substring to omit the special trademark symbol, I have tried a million different variations but I get no result. Here is my php code:

$sql = "SELECT * FROM txp_file WHERE filename LIKE '%$querytitle%' OR description LIKE '%$querytitle%'";
$query = mysql_query($sql) or die(mysql_error());
$result = mysql_fetch_array($query);
if ($result){
    echo "<a href='#'>$querytitle</a>";
}
else
    echo 'nil';

The connection to the database is already there so I don't need to do it again in this case. Can anyone find anything wrong with this code?

P.S. $querytitle is a global variable. I have echoed it and it comes up just the way it should.

  • 写回答

1条回答 默认 最新

  • duanou8504 2011-09-16 05:05
    关注

    You probably haven't set the character set for the connection. Use the command:

    SET NAMES utf8;
    

    or whatever character set you are using. To find the default character set of the database and the connection you can execute this command:

    USE yourdb;
    SHOW VARIABLES LIKE "%coll%";
    

    It will show you a list of collations for the server, the database and the connection.

    评论

报告相同问题?

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c