Jump to content

Coding help


alirulez

Recommended Posts

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

 

 

Link to comment
Share on other sites

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');

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.