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
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
Share on other sites

Error reporting is set to E_ALL and it is still only displaying the Fatal Error message.

 

The files are being included because if I force an error by putting some random letters in there is throws a PHP error......really do not understand what is going on!

Link to comment
Share on other sites

Yep the exit is just me finding the error and if I initiate inside the file then give the same error!!

 

Stupid thing is I just tested it on our live web server  and it runs fine so must be something to do with the PHP setup!

 

Thanks again for all the help!

Link to comment
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
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
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
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.