Admin Required Link

This is the right place to report general bugs, make suggestions or ask for help.
User avatar
WineMan
Posts: 106
Joined: Tue Sep 01, 2020 5:03 pm

Re: Admin Required Link

Post by WineMan » Wed Aug 10, 2022 2:59 pm

Yes, I know...I merely added that code to let him know that adding [exec] code [/exec] using the code I posted did not work.

George
Posts: 46
Joined: Tue May 18, 2021 10:54 am
Location: Uk
Contact:

Re: Admin Required Link

Post by George » Wed Aug 10, 2022 3:07 pm

you are going to have to give us more information
what version of flatpress are you using ?
what php version are you using ?
Proudly using flatpress https://www.mypoppy.uk/blog

User avatar
WineMan
Posts: 106
Joined: Tue Sep 01, 2020 5:03 pm

Re: Admin Required Link

Post by WineMan » Wed Aug 10, 2022 5:36 pm

Thanks for the follow up George.

I am using FlatPress version 1.2.1 and two different domains. One is running php version 5.6.39 and the other one is running php version 7.4.24

George
Posts: 46
Joined: Tue May 18, 2021 10:54 am
Location: Uk
Contact:

Re: Admin Required Link

Post by George » Wed Aug 10, 2022 6:35 pm

i think php version 5.6.39 is too out of date.
7.4 should be fine is your code working out of flatpress?
Proudly using flatpress https://www.mypoppy.uk/blog

User avatar
WineMan
Posts: 106
Joined: Tue Sep 01, 2020 5:03 pm

Re: Admin Required Link

Post by WineMan » Wed Aug 10, 2022 6:40 pm

Yes, the code is working out of FlatPress. It doesn't appear that it is going to work and I don't have the coding skills to develop a Plugin to set this up.

User avatar
Arvid
FlatPress Coder
Posts: 558
Joined: Sat Jan 26, 2019 7:40 pm
Contact:

Re: Admin Required Link

Post by Arvid » Sat Sep 17, 2022 12:32 pm

Your code, embedded in exec tags, works for me (I have no data.txt so I get the "The file cannot be found!" message).

But: Getting this error, exit is called. This stops every PHP execution immediately, so nothing else of your FlatPress will be displayed after that!
I'd recommend removing the exit and rework this in a more if/else fashion. Totally untested:

Code: Select all

if(!file_exists("data.txt")) {
	echo "The file cannot be found!";
}
else {
	$fp = fopen("data.txt", "r");
	if(!$fp) {
		echo "File cannot be opened";
	}
	else {
		echo "<table border = 2>";
		while(!feof($fp))
			{
				$info = fgets($fp);
				echo "<tr>";
				
				echo "<td>$info</td>\n";
				
				echo "<br />";
			}
			echo "</tr>\n";
			echo "</table>";
		fclose($fp);
	}
}
What I noticed: The code snippet you posted here misses the last semicolon after

Code: Select all

fclose($fp)
- could that be your initial problem?

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 50 guests