Jump to content

Error on different lines.


LeonLatex

Recommended Posts

I get an error on line 38, 39, 52, 56, 58, 63 and 71. I cant find the error. I am looking and looking 😮 
Can you help me find it?

<?php
class EntryPoint
{
	private $route;
	
	public function __construct($route)
	{
	$this->route = $route;
	$this->checkUrl();
	}
		
	private function checkUrl()
	{
		if ($this->route !== strtolower($this->route)) {
			http_response_code(301);
			header('location: ' . strtolower($this->route));
			
		}
	}
	
	private function loadTemplate($TemplateFileName, $variables = [])
	{
		extract($variables);
		
		ob_start();
		include __DIR__ . '/../templates/' . $templateFileName;
		
		include ob_get_clean();
	}

	private function callAction() 
	{
		include __DIR__ . '/../classes/databaseTable.php';
		include __DIR__ . '/../includes/dbconnection.php';
		
		$articleTable new DatabaseTable($pdo, 'article', 'id');
		$usersTable new DatabaseTable($pdo, 'users', 'id');
		
		if ($this->route === 'article/list') {
			include __DIR__ . '/../classes/controllers/articleController.php';
			$controller = new articleController($articleTable, $usersTable);
			$page = $controller->list();
		} elseif ($this->route === '') {
			include __DIR__ . '/../classes/controllers/articleController,php';
			$controller = new articleController($articleTable, $usersTable);
			$page = $controller->home();
		} elseif ($this->route === 'article/edit') {
			include __DIR__ . '/../classes/contollers/articleController.php';
			$controller = new articleController(articleTable, $usersTable);
			$page = Controller->edit();
		} elseif ($this->route === 'article/delete') {
			include __DIR__ . '/../classes/controllers/articleController.php';
			$controller = new articleController($articlesTable, $usersTable);
			$page $Controller->delete();
		} elseif ($this->route === 'register') {
			include __DIR__ '/../classes/controllers/registerController.php';
			$controller = new registerController($usersTable);
			$page = $controller->showForm();
		}	
		return $page
	}
	public function run()
	{
		$page = $this->callAction();
		$title = $page['title'];
	if (isset($page['variables'])) {
		$output = $this->loadTemplate($page['template'], $page['variables']);
	} else {
		output = $this->loadTemplate($page['template']);
	}
	include __DIR__ . '/../templates/layout.html.php';
	}
}

 

Link to comment
Share on other sites

Do these lines look right to you? A lot of careless mistakes. Aside from that, this is a very poorly written class. I suspect you didn't write this.

$articleTable new DatabaseTable($pdo, 'article', 'id');

$usersTable new DatabaseTable($pdo, 'users', 'id');

$page = Controller->edit();   

$controller = new articleController($articlesTable, $usersTable);   

$page $Controller->delete();

include __DIR__ '/../classes/controllers/registerController.php';  

return $page 

output = $this->loadTemplate($page['template']); 

 

 

Edited by benanamen
Link to comment
Share on other sites

When I woke up I took it immediately. There was missing everything from a . on one place to a $ on other places. Even a = and god knows what.

And Barand, maybe every error " are glaringly obvious" for you. Sometimes it isn't that for me. That's why I ask for help. This morning I could hardly hold my eyes open, but I want to fix the error, stubborn as I am.

And Benanamen, what makes you think I haven't written the script my self? I have taken some frome here and another from there, "IN MY OWN SCRIPTS". So yes, much of it is cut and paste, but it's from my own scripts written by my self 😠😤

Maybe it's just me, but I sometimes feel a certain undertone of arrogance in answers to me because I'm nowhere near as good as you at programming. That's why I'm asking the experts (you guys)for help. And it's not always as easy to see your own mistakes when you're so tired that you can barely keep your eyes up. Because it is not always as easy to go to sleep when you are engrossed in something. The cow should not forget that it has been a calf (a saying translated from Norwegian). All I want is to be friends with others with the same interest. And I am really struggling to get back where I once was.

Sorry if I am wrong and misunderstood. Feelings aren't always the same on the internet as in real life. I also include in the calculations that language barriers may arise.
Anyway, I appreciate the help I get when I get it.

Link to comment
Share on other sites

2 minutes ago, LeonLatex said:

And Barand, maybe every error " are glaringly obvious" for you.

Apparently they were for you too when you woke up... What changed? Did you then read the error messages?

2 minutes ago, LeonLatex said:

When I woke up I took it immediately. There was missing everything from a . on one place to a $ on other places. Even a = and god knows what.

 

Link to comment
Share on other sites

2 minutes ago, Barand said:

Apparently, they were for you too when you woke up... What changed? Did you then read the error messages?

 

No, I just looked over it and tried different things. I also compared it with other lines. It usually helps to get some sleep. I would think you recognize yourself in that.  😉 

Link to comment
Share on other sites

7 hours ago, dodgeitorelse3 said:

When you start a topic stating you got errors perhaps showing those error messages so we can see them as well as the code pertaining to those error messages. 

 

Yes, I know. I am aware of that, but sometimes I forget it. (just like others) Sorry for that, I am just a human 🤪  Anyway... I am always trying to behave and show (you)  my best side 😊

 

Link to comment
Share on other sites

@LeonLatex We all have those moments where something obvious escapes us. I think the responses you have received have the tone that they do because the problem (as posed) shows a lack of discipline and it appears you were not even trying. Plus, you never provided the error messages you were getting.

For example, how does one write all those lines of code and THEN discover all those syntax errors? I typically only write a "section" of code to do something specific, then run it to see that it is doing what I intend. Having typos is to be expected when writing code. What are you using as an editor? Most IDEs will highlight many basic typos.

  • Thanks 1
Link to comment
Share on other sites

Wow!  And I thought I was tough on people on the forums.  BUT  you are right.  Leon here does seem to throw stuff at us without any thought as to what he is showing us.  Perhaps he will slow down and think a bit more next time.  And to blame it on being tired is a terrible excuse.  (if you're that beat, stop and sleep on it and then think some more) To talk about error messages and line numbers but not show us the messages or the actual line that each is pointing to is kind of a waste of time.

Link to comment
Share on other sites

On 8/9/2022 at 11:37 PM, dodgeitorelse3 said:

That points me to suggest you may want to check your other scripts as well.

 

nah, I do it myself. I don't want to bother you more with it. Actually, i thought this was a site existing for helping and learning.

Instead of taking the shortcut and having some help here and saving time, I think it's best I use some extra time and find out about it by myself.

If I use a week or 3 months is not special important.
 

And about my comment, I said I was sorry if I was wrong, or something like that. On the 12th of October, I am going to Hua Hin in Thailand for six months.

So I will bring it with me to Thailand. I need something to do there as well.

The main reason I am learning so slow and remember very bad is because of a cognitive head injury after a traffic accident in 1988. Just sayin, if any wonder about it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.