开发者

Check sql match query

开发者 https://www.devze.com 2023-02-20 01:56 出处:网络
I have a wordpress post title $title = \'my post title\'; I have a table called interlinks where I store all my post titles, urls, and siteurls or my entire network.

I have a wordpress post title $title = 'my post title';

I have a table called interlinks where I store all my post titles, urls, and siteurls or my entire network.

This query matches my title with all the titles in the interlinks table.

Please check if my query is correct. Thank you. I have a feeling it's a big buggy.

$query_related_posts_network = mysql_query(
   "SELECT "
   "   posttitle, "
   "   posturl, "
   "   siteurl, "
   "   MATCH (posttitle,posturl,siteurl) AGAINST ('$titl开发者_JAVA技巧e') AS score "
   "FROM "
   "   interlinks "
   "WHERE "
   "   MATCH (posttitle,posturl,siteurl) AGAINST ('$title') AND "
   "   `siteurl` <> '$blogurl' "
   "LIMIT 15");


The only thing I can see is:

Don't forget to escape the string variables you put in your SQL queries, using mysql_real_escape_string().

$query_related_posts_network = mysql_query("SELECT posttitle, posturl, siteurl,
  MATCH (posttitle,posturl,siteurl) AGAINST ('".mysql_real_escape_string($title)."') AS score
  FROM interlinks
  WHERE MATCH (posttitle,posturl,siteurl) AGAINST ('".mysql_real_escape_string($title)."')
    AND `siteurl` <> '".mysql_real_escape_string($blogurl)."' LIMIT 15");
0

精彩评论

暂无评论...
验证码 换一张
取 消