techgnome
Mar 29th, 2009, 01:11 PM
This one has been kicking me for the last couple of days... and it's starting to tick me off... I've got some queries that I need to run via PHP against a mySQL database. For the most part, the queries work OK... the only time they don't seem to want to is when there are special characters in the search string.
I've got it printing out the sql, and when I then copy that sql and use it in the mySQL Query Browser, it returns the correct results.
$SAMQuery = "SELECT songlist.artist, album, label, count(trackno) as trackcount, albumyear FROM songlist
INNER JOIN categorylist ON songlist.ID = categorylist.songID
INNER JOIN category ON categorylist.categoryID = category.ID
WHERE (category.name = 'Current Tracks') AND (songlist.songtype='S') AND (songlist.artist = '".$artistName."')
GROUP BY songlist.artist, album, label, albumyear
ORDER BY album";
$SAMdb->open($SAMQuery);
That's the code I'm using to call the query.... if I use "queen" .. as the $artistName, then I get back results correctly -- all albums by Queen. BUT, if I use "Queensr˙che" ... the results are empty... and I should get 1 result. I've also found this to happen if I'm searching for something with an ampersand in it too....
Is there something I'm missing?
If you want to see it in action try this link (http://tannagh.com/playlist.php?searchfor=1&browse=&letter=&album=&artist=&year=&trackid=&searchby=artist&searchtext=queen&doSearch=Search) ... you'll get the resutls for a search on "queen" ... there's two links, one for Queen that returns results, and one for Queensr˙che that claims to return no results (should return 1).
-tg
I've got it printing out the sql, and when I then copy that sql and use it in the mySQL Query Browser, it returns the correct results.
$SAMQuery = "SELECT songlist.artist, album, label, count(trackno) as trackcount, albumyear FROM songlist
INNER JOIN categorylist ON songlist.ID = categorylist.songID
INNER JOIN category ON categorylist.categoryID = category.ID
WHERE (category.name = 'Current Tracks') AND (songlist.songtype='S') AND (songlist.artist = '".$artistName."')
GROUP BY songlist.artist, album, label, albumyear
ORDER BY album";
$SAMdb->open($SAMQuery);
That's the code I'm using to call the query.... if I use "queen" .. as the $artistName, then I get back results correctly -- all albums by Queen. BUT, if I use "Queensr˙che" ... the results are empty... and I should get 1 result. I've also found this to happen if I'm searching for something with an ampersand in it too....
Is there something I'm missing?
If you want to see it in action try this link (http://tannagh.com/playlist.php?searchfor=1&browse=&letter=&album=&artist=&year=&trackid=&searchby=artist&searchtext=queen&doSearch=Search) ... you'll get the resutls for a search on "queen" ... there's two links, one for Queen that returns results, and one for Queensr˙che that claims to return no results (should return 1).
-tg