Jump to content

PHP Class Not Found


JDMallion

Recommended Posts

Hi Guys,

 

I am trying to build my application on my local test server (I have tried both WAMP and XAMPP just in case they were the problem) and I just keep getting the following error:

 

Fatal error: Class 'MySQL' not found in C:\xampp\htdocs\webaddress.co.uk\php\core.php on line 44

 

The class file is being included because if I force an error in the file then it picks it up and displays an error!

 

The code for including the class file is:

 

switch ( database_type )
{
case "MySQL":
	require_once ( core_dir."class.my-sql.php" );
	$db = new MySQL( database_host, database_user, database_password, database_name );
	$db->setNames( "utf8" );
	break;
}

 

Really at a loss and any help would be appreciated!  :wtf:

Link to comment
https://forums.phpfreaks.com/topic/206046-php-class-not-found/
Share on other sites

Nope, I have a class called MySQL. But it is not just an issue with this specific class I just commented out the MySQL class and the smarty class that is being include below throws  the same error!  :'(

 

require_once ( smarty_dir."Smarty.class.php" );
$tpl = new Smarty();

Link to comment
https://forums.phpfreaks.com/topic/206046-php-class-not-found/#findComment-1078125
Share on other sites

Is your live server also a Windows server and using the same php version as where your code does not work, because php.net has had a lot of bugs concerning resolving include/require paths and getting the _once versions to see the correct files.

 

Do you have more than one class.my-sql.php file present in other folders?

 

Does this work if you just use require() and not the _once version?

 

What is your core_dir value?

 

 

Link to comment
https://forums.phpfreaks.com/topic/206046-php-class-not-found/#findComment-1078384
Share on other sites

The response to the var_dump was:

 

string(45) "http://localhost/webaddress.co.uk/php/" bool(false)

 

and throwing an exit; before the class is declared I get the same message:

 

Fatal error: Class 'MySQL' not found in C:\xampp\htdocs\webaddress.co.uk\php\core.php  on line 44

 

So looks like the class is just not being declared!! For some damn reason!  :confused:

Link to comment
https://forums.phpfreaks.com/topic/206046-php-class-not-found/#findComment-1078607
Share on other sites

Is your live server also a Windows server and using the same php version as where your code does not work, because php.net has had a lot of bugs concerning resolving include/require paths and getting the _once versions to see the correct files.

 

Do you have more than one class.my-sql.php file present in other folders?

 

Does this work if you just use require() and not the _once version?

 

What is your core_dir value?

 

 

 

Does not work with require or include, have tried that one :)

 

Do not have more than one class and my core path is:

 

http://localhost/webaddress.co.uk/php/

 

Just had a thought the use of a URL could have something to do with it, but I have turned on the setting that allows URLs.

Link to comment
https://forums.phpfreaks.com/topic/206046-php-class-not-found/#findComment-1078608
Share on other sites

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.