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 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. 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? 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
Archived
This topic is now archived and is closed to further replies.