Nothadoth Posted July 6, 2007 Share Posted July 6, 2007 I am using this to define a variable: $cat = $nav['name']; It works because if i tell it to echo that variable it does return words such as "The Club" which is what I want. But when I select to select from a database table it doesn't work - i'll use this code (database is already connected to): $querysubnav = mysql_query("SELECT * FROM nav WHERE category='$cat' ORDER BY id ASC"); It doesn't give any results when i display the data. However if i change it to category='The Club' it does give the results I want. But I know that the variable $cat contains "The Club" anyway. Anyone help me? Ive even tried putting category='$nav['name']' and it didn't work. Link to comment https://forums.phpfreaks.com/topic/58654-question/ Share on other sites More sharing options...
hackerkts Posted July 6, 2007 Share Posted July 6, 2007 Hmm.. What about $querysubnav = mysql_query("SELECT * FROM nav WHERE category='".$cat."' ORDER BY id ASC"); Link to comment https://forums.phpfreaks.com/topic/58654-question/#findComment-290978 Share on other sites More sharing options...
teng84 Posted July 6, 2007 Share Posted July 6, 2007 echo your query then give us the result echo "SELECT * FROM nav WHERE category='$cat' ORDER BY id ASC"; Link to comment https://forums.phpfreaks.com/topic/58654-question/#findComment-290981 Share on other sites More sharing options...
Nothadoth Posted July 6, 2007 Author Share Posted July 6, 2007 hackerkts: didn't work teng: how do i echo that :S sorry my mind frazzled at the moment been up all night and im new at this lol Link to comment https://forums.phpfreaks.com/topic/58654-question/#findComment-290985 Share on other sites More sharing options...
Nothadoth Posted July 6, 2007 Author Share Posted July 6, 2007 Sorry i think i did it: Came back with "Resource id #6" :S Link to comment https://forums.phpfreaks.com/topic/58654-question/#findComment-290988 Share on other sites More sharing options...
hackerkts Posted July 6, 2007 Share Posted July 6, 2007 Actually the query on the first thread should works, not sure why it didn't work for you in the first place.. Link to comment https://forums.phpfreaks.com/topic/58654-question/#findComment-291084 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.