alirulez Posted September 2, 2010 Share Posted September 2, 2010 Hi All I am fairly new to the PHP world so please excuse my ignorance. (I am trying!) Basically I bought a commercially available PHP script and created my own script to work alongside the bought one. What happened then is that the developers of the script I bought released a new version of the software. My script no longer works and is throwing up the following error PHP Fatal error: Using $this when not in object context in C:\wamp\www\classifieds\system\core\System.php on line 175 I've worked out that the script fails on this line, in the new version of the software. $dbhost = System::getSystemSettings('DBHOST'); On review of the commercial script's coding, I noticed that where the old version used the syntax above, the new version uses a syntax as shown below $this->appContext->getSystemSettings('DBHOST'); So I went and modified my script (mismatched.php) to read as follows $dbhost = $this->appContext->getSystemSettings('DBHOST'); But im now getting the following errors PHP Parse error: syntax error, unexpected T_REQUIRE_ONCE, expecting T_FUNCTION in C:\wamp\www\classifieds\admin\mismatched.php on line 5 I'd appreciate any ideas you may have that could help me get my script (mismatched.php) working again. Thanks again Ali Quote Link to comment https://forums.phpfreaks.com/topic/212382-coding-help/ Share on other sites More sharing options...
samshel Posted September 2, 2010 Share Posted September 2, 2010 Can you post some code in your script, it is a parse error. If the new version of the script you bought is working fine alone, that means the parse error is in your script. Posting some code will help to find out what the parse error is. Quote Link to comment https://forums.phpfreaks.com/topic/212382-coding-help/#findComment-1106642 Share on other sites More sharing options...
alirulez Posted September 2, 2010 Author Share Posted September 2, 2010 Hi. Yes the new version of the standalone script works fine. My original script - which I use as an extention to the commercial script, (Mismatch.php), which used to work with the old version of the script is as follows: <?php require_once('../system/core/System.php'); System::loadSystemSettings ('../system/user-config/LocalSettings.php'); $dbhost = System::getSystemSettings('DBHOST'); $dbname = System::getSystemSettings('DBNAME'); $dbuser = System::getSystemSettings('DBUSER'); $dbpass = System::getSystemSettings('DBPASSWORD'); $con = mysql_connect($dbhost, $dbuser, $dbpass); mysql_select_db($dbname, $con); $result = mysql_query("SELECT * FROM mpesa_mismatch ORDER BY date"); if (!$result) { die('Invalid query: ' . mysql_error()); } echo ' <table align="center"> <tr bgcolor="#A6A6A6"> <td width="100"><b>Date</b></td><td width="100"><b>Payment_id</b></td><td width="100"><b>Amount</b></td><td width="100"><b>Action</b></td> </tr>'; while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) { echo ' <tr bgcolor="#4F518E"> <td><font color="#FFFFFF">' . $row['date'] . '</font></td><td><font color="#FFFFFF">' . $row['pay_id'] . '</font></td><td><font color="#FFFFFF">' . $row['amount'] . '</font></td><td><a href="deletemis.php?id=' . $row['id_mis'] . '"><font color="#FFFFFF">Delete</font></a></td>'; } echo '</table>'; mysql_close($con); ?> I tried to replace line 5 - 8 with the following syntax but then got the error messages described in my first post $dbhost = $this->appContext->getSystemSettings('DBHOST'); $dbname = $this->appContext->getSystemSettings('DBNAME'); $dbuser = $this->appContext->getSystemSettings('DBUSER'); $dbpass = $this->appContext->getSystemSettings('DBPASSWORD'); Quote Link to comment https://forums.phpfreaks.com/topic/212382-coding-help/#findComment-1106649 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.