Jump to content

[SOLVED] Using php to echo mysql rows.


whelpton

Recommended Posts

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 '';

Link to comment
https://forums.phpfreaks.com/topic/150378-solved-using-php-to-echo-mysql-rows/
Share on other sites

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';
}

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.