Jump to content
TNG Community
kempons

Updating code for PHP 7.2

Recommended Posts

kempons

Hi,

I have the following custom code in my index.php file which is working fine.

$query = "SELECT count(id) as pcount FROM $people_table $wherestr";  
$result =  tng_query($query) or die ("$text[cannotexecutequery]: $query");  
$row = tng_fetch_assoc( $result ); 
$totalpeople = number_format ($row[pcount]); tng_free_result($result); 

$query = "SELECT DATE_FORMAT(lastimportdate,\"%e %b %Y\") as lastimportdate2 FROM $trees_table";
$result = tng_query($query) or die ($text['cannotexecutequery'] . ": $query");
$treerow = tng_fetch_array( $result, MYSQL_ASSOC );
$lastimportdate = $treerow['lastimportdate2'];

 

When updating to php v7.2, it throws the following errors. Can anyone assist in advising the update required to remove these errors?

PHP Warning:  Use of undefined constant pcount - assumed 'pcount' (this will throw an Error in a future version of PHP) in /home/kempfamily/public_html/templates/template8/index.php on line 5

PHP Warning:  Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in /home/kempfamily/public_html/templates/template8/index.php on line 19

 

Thanks.

 

Share this post


Link to post
Share on other sites
Newfloridian

The warning is telling you that you need to enclose your variable names in single quotes ('pcount' for pcount etc). Have a look at the lines in your .template8/index.php file indicated in the warning message and add the single quotes where indicated 

Alan

 

Share this post


Link to post
Share on other sites
kempons

Thanks Alan

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×