whelpton Posted March 20, 2009 Share Posted March 20, 2009 Okay, essentially I am trying to: Take usernames from a mysql database & echo certain variables contained in their profiles. I have got this part pretty much sorted, now; what I need to figure out is how to not echo a user that has a certain word in their profile. For example: The username VincentWhite will not display if their included file says Default Name. This might seem confusing, so heres the code that I'm using, it might be easier to figure out whats wrong with the code than listening to me give a bad explanation. $check echo '/home/alport/public_html/'.$row['Username'].'/text/name.txt'; if ($check == 'Default Name'); {}else{ echo ''; exit; } echo '<h2>'; include '/home/alport/public_html/'.$row['Username'].'/text/name.txt';}} echo '</h2>'; if ($_POST['Username'] = $row['Username']){echo '';} echo ''; Quote Link to comment https://forums.phpfreaks.com/topic/150378-solved-using-php-to-echo-mysql-rows/ Share on other sites More sharing options...
wildteen88 Posted March 20, 2009 Share Posted March 20, 2009 You could use strpos $profileTXT = file_get_contents('/home/alport/public_html/'.$row['Username'].'/text/name.txt'); if(!strpos($profileTXT, 'Default User')) { echo 'Display profile here'; } else { echo 'do someting else, Default User present in file'; } Quote Link to comment https://forums.phpfreaks.com/topic/150378-solved-using-php-to-echo-mysql-rows/#findComment-789722 Share on other sites More sharing options...
whelpton Posted March 20, 2009 Author Share Posted March 20, 2009 Thanks, just what I was looking for. Quote Link to comment https://forums.phpfreaks.com/topic/150378-solved-using-php-to-echo-mysql-rows/#findComment-789724 Share on other sites More sharing options...
whelpton Posted March 20, 2009 Author Share Posted March 20, 2009 Actually, that dosnt seem to work. Is there a possibility that File_get_contents can be disabled on certain servers? That function never seems to work for me. And is there any other way of doing it? Quote Link to comment https://forums.phpfreaks.com/topic/150378-solved-using-php-to-echo-mysql-rows/#findComment-789732 Share on other sites More sharing options...
whelpton Posted March 20, 2009 Author Share Posted March 20, 2009 Never Mind, I fixed it using: if ($profileTXT == "Default Name") { echo 'Epic Fail'; } else { echo '<h2>'; include '/home/alport/public_html/'.$row['Username'].'/text/name.txt';}} echo '</h2>'; if ($_POST['Username'] = $row['Username']){echo '';} echo ''; } But, does anyone know if filegetcontents can be disabled on certain servers? This is really bugging me now. Quote Link to comment https://forums.phpfreaks.com/topic/150378-solved-using-php-to-echo-mysql-rows/#findComment-789735 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.