The Little Guy Posted April 7, 2008 Share Posted April 7, 2008 Why does this: <?php $function = $_GET['function']; $query = "SELECT * FROM `functions` WHERE `function` = 'random' LIMIT 1"; $sql = mysql_query($query); ?> only return a result if all fields are filled in, in the database for that record? Quote Link to comment https://forums.phpfreaks.com/topic/100005-select-not-working/ Share on other sites More sharing options...
wildteen88 Posted April 7, 2008 Share Posted April 7, 2008 You are limiting the query to return only 1 result. This is why you are getting only one result. Remove LIMIT 1 from the query. Quote Link to comment https://forums.phpfreaks.com/topic/100005-select-not-working/#findComment-511392 Share on other sites More sharing options...
cooldude832 Posted April 7, 2008 Share Posted April 7, 2008 is function a integer? Quote Link to comment https://forums.phpfreaks.com/topic/100005-select-not-working/#findComment-511400 Share on other sites More sharing options...
The Little Guy Posted April 7, 2008 Author Share Posted April 7, 2008 You are limiting the query to return only 1 result. This is why you are getting only one result. Remove LIMIT 1 from the query. Still can not find it is function a integer? Nope it is a string: varchar(255) Quote Link to comment https://forums.phpfreaks.com/topic/100005-select-not-working/#findComment-511410 Share on other sites More sharing options...
The Little Guy Posted April 7, 2008 Author Share Posted April 7, 2008 You are limiting the query to return only 1 result. This is why you are getting only one result. Remove LIMIT 1 from the query. B.T.W. I do only want one result no more than that Quote Link to comment https://forums.phpfreaks.com/topic/100005-select-not-working/#findComment-511417 Share on other sites More sharing options...
cooldude832 Posted April 7, 2008 Share Posted April 7, 2008 if your functions are unique say you want to do function eat an apple then don't pass its title but pass its functionID number in mysql across then you are always sure you get the right result. A varchar compare has 100 more ways to fail than an integer to integer compare Quote Link to comment https://forums.phpfreaks.com/topic/100005-select-not-working/#findComment-511421 Share on other sites More sharing options...
craygo Posted April 7, 2008 Share Posted April 7, 2008 Is there more code than that cause you won't get much from just that just the resource id which doesn't mead much. This will list field name and value <?php $sql = "SELECT * FROM `roster` WHERE sort = 1"; $res = mysql_query($sql) or die(mysql_error()); $r = mysql_fetch_assoc($res); foreach($r as $key => $val){ echo "$key = $val<br />"; } ?> Ray Quote Link to comment https://forums.phpfreaks.com/topic/100005-select-not-working/#findComment-511427 Share on other sites More sharing options...
The Little Guy Posted April 7, 2008 Author Share Posted April 7, 2008 Well... The line above just includes the database connection information. I don't want to pass an ID number, because the manual I am making has the same "Format" as PHP.net, where you just type in: http://sitename.com/random or http://sitename.com/abs and it will take you to that function. I have never had this issue before... Quote Link to comment https://forums.phpfreaks.com/topic/100005-select-not-working/#findComment-511443 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.