PDA

View Full Version : Why Does Attempting This Kill ShopWindow Client?


Raid
28-01-10, 19:28
I am trying unsuccessfully to pass a new variable I've created from an external file such as productlist.php into the shopcore class.

I've amended the code in class.smarty_sw.php as follows:

require_once('class.shopcore.php');
//new
$shopcore->SetKeyphrasePage( $KeyphrasePage );

The new line is supposed to just call my new SetKeyphrasePage function to assign the value of my KeyphrasePage variable. What it actually does is totally interrupt ShopWindow functionality, so that I just get a completely blank page with no output.

Obviously, I'm interfering with a key class file with that new line.

So, if the class has been instantiated with the require_once line, how am I supposed to send it a value for a variable? :confused:

Any pointers guys? ;)

Thanks :)

Raid
28-01-10, 19:34
Would it be anything to do with the fact that it is a once statement, and therefore you can't get back into it after the require_once line???

Thanks :cool:

CaptainFalcon
29-01-10, 10:45
If you are getting a blank page then a fatal error is occuring. In your constants.inc.php file you should have ini_set('error_reporting', 0) or something similar. Change the 0 to a 1 and errors should be displayed.

Most likely, your require_once is failing as your shopcore is located in the classes directory. I suggest trying require_once('classes/class.shopcore.php');

HTH

Raid
29-01-10, 17:46
CaptainFalcon, many thanks for the tip on switching on error reporting. I can now see the error I'm getting, which is:

Fatal error: Call to a member function SetKeyphrasePage() on a non-object in /home/mysite/public_html/classes/class.smarty_sw.php on line 30

So this line:

$shopcore->SetKeyphrasePage( $KeyphrasePage );

Is causing the error, because I'm referencing the $shopcore object, which has not been instantiated.

The shopcore class code is "getting run" because of this line:

require_once('class.shopcore.php');

but the way it is "getting run" is not instantiating the shopcore class which it contains.

So, I guess I should be instantiating an instance of the shopcore class using the new statement in order to be able to send the class a variable??? Something like:

$shopcore = new shopcore;

Thanks for any thoughts.

Rgds :cool:

CaptainFalcon
29-01-10, 17:48
try

$shopcore = new shopcore();