phpdave11 / php-survey-builder

A PHP web application that lets you create surveys and collect survey responses. Uses SQLite3 by default and also supports MySQL and PostgreSQL.
MIT License
71 stars 47 forks source link

Cannot redeclare class Controller #2

Closed Zendiver closed 4 years ago

Zendiver commented 6 years ago

Sorry, I am also somewhat of a newbie. I am running XAMPP and all my other projects are running fine but when I add a new project dev.suryvey.zendiver.net, I get the following error:

Fatal error: Cannot redeclare class Controller in D:\wamp\www\net.zendiver.survey\controllers\Controller.php on line 17

I have made sure the data/ file was writeable.

Thank you in advance

phpdave11 commented 6 years ago

This could happen if the Controller class somehow got included more than once.

Have you modified any of the code?

Without seeing the code that is causing the issue, it is hard to say what the cause of the problem is. If you want to share the code with me, I would be happy to look into the issue more.

Zendiver commented 6 years ago

Thank you Dave. Which file would you like me to send. I have not made any changes to the original files.

Matter of fact, I downloaded the files again and tried a new dev environment and get the same issue. This happens after the login screen survey_login

When I click on Login, I get the following: Fatal error: Cannot redeclare class Controller in E:\websites\com.bailey.survey\controllers\Controller.php on line 17

I have attached the Controller.php file (remove the .txt extension) Controller.php.txt

phpdave11 commented 6 years ago

As a test, I just installed XAMPP and extracted the php-survey-builder files to C:\xampp\htdocs\php-survey-builder. I went to http://localhost/php-survey-builder and got an error message about sqlite not being enabled:

screenshot1

I enabled this sqlite3 extension in my php.ini file, then I stopped and started apache. Now I am able to log in without any errors:

screenshot2

Do you have any other projects installed with XAMPP? They may somehow be conflicting with the Controller class in php-survey-builder.

efcjunior commented 6 years ago

The library is enabled on xampp,but the error continue. Probably there are some requirements.

hamidionline commented 5 years ago

Hi I have the same Error in Wamp Server

Thank you Dave. Which file would you like me to send. I have not made any changes to the original files.

Matter of fact, I downloaded the files again and tried a new dev environment and get the same issue. This happens after the login screen survey_login

When I click on Login, I get the following: Fatal error: Cannot redeclare class Controller in E:\websites\com.bailey.survey\controllers\Controller.php on line 17

I have attached the Controller.php file (remove the .txt extension) Controller.php.txt

phpdave11 commented 5 years ago

@hamidionline can you please put this code at the top of Controller.php, and let me know the result?

$reflector = new ReflectionClass('Controller');
echo $reflector->getFileName();
exit;
raul-mg commented 5 years ago

Return the phisical route to Controller.php class file

alexroyce315 commented 5 years ago

Replace require with require_once should solve this issue.

Before: require 'controllers/Controller.php'; After: require_once 'controllers/Controller.php';

smixy commented 5 years ago

The XAMPP and enabling the sqlite3 from php.ini worked for me! I really liked your work or how can we migrate from sqlite3 to mysql. Thank you

phpdave11 commented 5 years ago

@smixy it should be pretty easy to get this working with MySQL instead of SQLite3. First, make sure data/schema.sql is compliant with MySQL. Next, update the DSN in configs/Database.ini. Finally, modify the openDatabase() function in controllers/Controller.php so that 'filename' isn’t a required setting.

smixy commented 5 years ago

@phpdave11 i got this error PDOException: SQLSTATE[HY000] [1045] Access denied for user ''@'localhost' (using password: NO)

phpdave11 commented 5 years ago

@smixy some extra code was needed to pass in the username and password to PDO. Version 1.1.0 fixes this.

smixy commented 5 years ago

@phpdave11 Everything is working now, Thank you for your efforts.

damacreg commented 5 years ago

Hi, I have set up the Survey Builder on a Windows 10 Server using IIS Fastcgi. I have tried both php5 and php7 and get the same error result as mentioned above:

I have enabled sqlite3 and the login page works.

When I click on Login, I get the following: Fatal error: Cannot redeclare class Controller in C:\inetpub\wwwroot\PHP\PHPSurvey\controllers\Controller.php on line 17

I tried this: Replace require with require_once should solve this issue.

Before: require 'controllers/Controller.php'; After: require_once 'controllers/Controller.php';

note this require appears in several files, I have tried changing all of them to require_once. If I change require to require_once I get the following error: PHP Fatal error: Class 'Login' not found in C:\inetpub\wwwroot\PHP\PHPSurvey\controllers\LoginController.php on line 28

anyone any further ideas?

phpdave11 commented 5 years ago

@damacreg can you please put this code at the top of Controller.php, and let me know the result?

$reflector = new ReflectionClass('Controller');
echo $reflector->getFileName();
exit;
damacreg commented 5 years ago

Hi Dave,

Here is the result:

C:\inetpub\wwwroot\PHP\PHPSurvey\controllers\Controller.php

Kind Regards

Eddie

phpdave11 commented 5 years ago

@damacreg I have fixed this bug in v1.1.1

damacreg commented 5 years ago

Hi Dave,

Thanks, does this work with PHP 7 or only 5

Kind Regards

Eddie

phpdave11 commented 5 years ago

It works on both PHP 7 and PHP 5 (version 5.4 or higher).

damacreg commented 5 years ago

Hi Dave,

I’m trying it on php 7.3.1 and whichever page I try to access it goes to http://localhost/PHPSurvey/login.php and I just get a blank screen,

Any ideas?

No errors show up in chrome developer tools

Kind Regards

Eddie

geoffreynzomo commented 5 years ago

Hello Dave,

Trying to use the new php survey builder 1.1.1 but I am getting a blank scree on login page

phpdave11 commented 5 years ago

@damacreg @geoffreynzomo the blank screen on login page bug has been fixed in v1.1.2

damacreg commented 5 years ago

That's great thanks, it is working now

geoffreynzomo commented 5 years ago

Thanks Dave, its fine now.