hello123456789 Posted December 11, 2008 Share Posted December 11, 2008 I am trying to write a search bar for a website i was making. Everything seems to go well until it finishes displaying the first search result, even if there are many more search results. Here is the part of the script for displaying the search results: function short_description($des) { $final = ""; $final = (substr($des, 0, 200)."..."); echo "<p>".strip_tags($final)."</p>"; } while($pagerow = mysql_fetch_assoc($pageres)) { echo "<h2><a href = 'discussion.php?id=".$pagerow['id']."'>".$pagerow['name']."</a></h2>"; echo "Posted on ".date("D jS F Y g.iA", strtotime($pagerow['dateposted'])); short_description($pagerow['body']) or die(mysql_error()); // Executes this line and stops here } I figured the problem might have to do with the line with "short_description" because I tried adding and echo in the next line but it wouldn't appear, though I am not entirely sure if this is the source of the problem. Any help would be greatly appreciated. Thanks! Link to comment https://forums.phpfreaks.com/topic/136458-search-bar-problem/ Share on other sites More sharing options...
ted_chou12 Posted December 11, 2008 Share Posted December 11, 2008 Hi there, from the code you've shown here, everything seems to be okay, maybe you can post other codes of your script. Ted. Link to comment https://forums.phpfreaks.com/topic/136458-search-bar-problem/#findComment-712251 Share on other sites More sharing options...
blueman378 Posted December 11, 2008 Share Posted December 11, 2008 sorry i dont get this; short_description($pagerow['body']) or die(mysql_error()); // Executes this line and stops here why are you trying to show a mysql error for the function? i have a feeling the function is returning a value other than 0 so it is considering it as failed. try changing it to short_description($pagerow['body']) or die("error in function"); and you will proborably get error in function printed. let me know how it goes Link to comment https://forums.phpfreaks.com/topic/136458-search-bar-problem/#findComment-712280 Share on other sites More sharing options...
hello123456789 Posted December 13, 2008 Author Share Posted December 13, 2008 Thanks blueman378, I replaced "mysql_error()" with "error in function", and it printed "error in function" like you said. I just don't know what exactly the error is in the function. Any help would be greatly appreciated. Thanks! Link to comment https://forums.phpfreaks.com/topic/136458-search-bar-problem/#findComment-714431 Share on other sites More sharing options...
corbin Posted December 13, 2008 Share Posted December 13, 2008 There isn't an error in the function. x or y means evaluate x, and if it's true continue into the branch. If it's false, evaluate y and go into the branch if it's true. The only time a function is considered true is if it returns a value equivalent (in PHP world) to true. true or 1 pretty much. The or doesn't even make sense there, by the way. Just change it to short_description($pagerow['body']); Link to comment https://forums.phpfreaks.com/topic/136458-search-bar-problem/#findComment-714433 Share on other sites More sharing options...
hello123456789 Posted December 13, 2008 Author Share Posted December 13, 2008 Thanks, it worked! Thank you very much for your patience! Link to comment https://forums.phpfreaks.com/topic/136458-search-bar-problem/#findComment-714435 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.