0

Hi i am trying create a tag filtering function where images can be filtered using tags. Specifically i am having trouble passing the tagz array, this may be down to my table setup, either way any help with the SQL or any other part of the code would be greatly appreciated. Thanks in advance.

<?php
    if (@mysql_connect('*****','*****','****')) {
        if (mysql_select_db('****')) {
            $tagz = $_REQUEST['tagz'];
            $tagz = mysql_real_escape_string($tagz);
            $tagz = implode(", ", $tagz);

            $query = " SELECT boxes . BNO, boxes . BName, boxes . URL, images . Ipath FROM boxes LEFT JOIN images ON boxes . INO = images . INO LEFT JOIN links ON boxes . BNO = links . BNO WHERE links . TNO LIKE '$tagz' ";
            $query_run = mysql_query($query);
        } while ($query_row = mysql_fetch_assoc($query_run)) {
            echo $row ='<li id='.$query_row['BNO'].' class="box">;
        }
    }

?>
1
  • add var_dump($_REQUEST['tagz']) to see waht that has in it. Do you not want $_GET or $_POST instead? Commented Nov 16, 2012 at 0:18

1 Answer 1

1

Have you tried to echo out $tagz and then execute the SQL manually to ensure it works? Might just be a logic issue within the SQL or a dud character breaking the SQL.

Also consider switching to mysqli or pdo, it'll eliminate the need to escape_string tagz.

Sign up to request clarification or add additional context in comments.

1 Comment

+1 for mysqli/pdo. They will save you a ton of headaches from trying to figure out what to sanitize.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.