ivanella Posted April 28, 2008 Share Posted April 28, 2008 I guys, i'm sorry for my english but i'm italian girl. I need help for this script: $sql = "SELECT link_title FROM film_links WHERE '{$attori}' LIKE CONCAT( '%', link_field6, '%' )"; it dosnt work, do you know why??? thanks for help.... Quote Link to comment Share on other sites More sharing options...
dptr1988 Posted April 28, 2008 Share Posted April 28, 2008 I'm not sure if this is the problem but it looks like your values are reversed in the 'LIKE' part Try this: <?php $sql = "SELECT link_title FROM film_links WHERE link_field6 LIKE '%{$attori}%' "; ?> Quote Link to comment Share on other sites More sharing options...
Rohan Shenoy Posted April 28, 2008 Share Posted April 28, 2008 Try if this works: $sql = "SELECT link_title FROM film_links WHERE $attori LIKE '%$link_field6%')"; Quote Link to comment Share on other sites More sharing options...
dptr1988 Posted April 28, 2008 Share Posted April 28, 2008 Rohan Shenoy: 'link_field6' appears to be a SQL field name, rather then a PHP variable Quote Link to comment Share on other sites More sharing options...
Rohan Shenoy Posted April 28, 2008 Share Posted April 28, 2008 ^ya true, looks like to me too but u never know what the db table structure is like. Quote Link to comment Share on other sites More sharing options...
ivanella Posted April 28, 2008 Author Share Posted April 28, 2008 $link_field6 is a field of database that conteins values like: "Marco" or "Luca" or "Anna" while $attori is a variabile with values like: "Marco Luca Anna" ....thanks for help.... Quote Link to comment Share on other sites More sharing options...
dptr1988 Posted April 28, 2008 Share Posted April 28, 2008 ivanella: Did you try my example? Did it work? Rohan Shenoy: Yes, and it's always good to try everything possible and get everyones ideas. More brains are better then one. Note: If you want to get really, really, really, really, technical, there are 5 indications that the name 'attori' is a PHP variable and none of those 5 indicators appear on the 'link_field6' fieldname. Those find indicators are left and right single quotes, left and right curly brackets and the dollar sign. A SQL field name would not be quoted in a situation like this, would never have the curly brackets or the dollar sign. So if the person writing this code put all of those characters in on one PHP variable that indicated it was a PHP variable, there is a good chance that they would also at least include 1 of those indicators on the 'link_field6' name. Also the word 'field' appears in 'link_field6' which also suggests that could be a SQL field name. Quote Link to comment Share on other sites More sharing options...
dptr1988 Posted April 28, 2008 Share Posted April 28, 2008 If your $attori variable contains multiple names like you mentioned, you can replace all of the spaces between the names with '%' before using it in the SQL query, so that it would match each word in it rather then the whole string. <?php $attori = str_replace(' ', '%', $attori); ?> Quote Link to comment Share on other sites More sharing options...
Rohan Shenoy Posted April 28, 2008 Share Posted April 28, 2008 @dptr 1988 Thanks dude! Quote Link to comment Share on other sites More sharing options...
soycharliente Posted April 28, 2008 Share Posted April 28, 2008 I think she said it would contain a name LIKE those. Not a list of names. I'm fairly confident that dptr's solution is what she needs. <?php $sql = "SELECT `link_title` FROM `film_links` WHERE `link_field6` LIKE '%{$attori}%'"; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.