prallen Posted March 9, 2010 Share Posted March 9, 2010 okay, my table looks something like this ID UniqueID FileName 1 nCSoHUaDMz nCSoHUaDMz.jpg 2 XXXXXXXXXX XXXXXXXXXX.jpg 3 XXXXXXXXXX XXXXXXXXXX.jpg I am trying to get the FileName based on the UniqueID. This is what I am trying: ShowRandomPic(); function ShowRandomPic(){ mysql_connect("localhost", "db_user", "db_password") or die ('Error: ' . mysql_error()); mysql_select_db ("db_pictures"); $sql = "SELECT * FROM table Where UniqueID = 'nCSoHUaDMz'"; $result = mysql_query($sql); $row = mysql_fetch_array($result); $filename = $row['FileName']; print $filename; } Nothing is outputting, any Ideas or suggestions? Thanks a lot, Pat Quote Link to comment https://forums.phpfreaks.com/topic/194680-using-select-__-from-table-where-to-get-filename-from-a-table/ Share on other sites More sharing options...
premiso Posted March 9, 2010 Share Posted March 9, 2010 Try removing the whitespace after the UniqueID = ' $sql = "SELECT * FROM table Where UniqueID = 'nCSoHUaDMz'"; As MySQL will actually look for " asdfasear" you have to be exact or use the LIKE statement. Quote Link to comment https://forums.phpfreaks.com/topic/194680-using-select-__-from-table-where-to-get-filename-from-a-table/#findComment-1023827 Share on other sites More sharing options...
prallen Posted March 9, 2010 Author Share Posted March 9, 2010 Thanks for the reply, Thats not it though, I must have accidentally put a space in when i C&Ped it... Any more Ideas? Quote Link to comment https://forums.phpfreaks.com/topic/194680-using-select-__-from-table-where-to-get-filename-from-a-table/#findComment-1023828 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.