- Posts: 42
- Thank you received: 0
PHP 7 support
7 years 5 months ago #4096
by sakattack
PHP 7 support was created by sakattack
Hello
I just tried out PHP 7 with the component and everything works fine except one pro feature.
The file you have provided the pro customers that displays an intermediate splash screen on product click (like "you are now going to the shop to see that product" etc etc) uses mysql functions which have been removed from PHP 7.
Is it possible to provide us with an updated version that uses mysqli functions instead?
Thank you
I just tried out PHP 7 with the component and everything works fine except one pro feature.
The file you have provided the pro customers that displays an intermediate splash screen on product click (like "you are now going to the shop to see that product" etc etc) uses mysql functions which have been removed from PHP 7.
Is it possible to provide us with an updated version that uses mysqli functions instead?
Thank you
Please Log in or Create an account to join the conversation.
7 years 5 months ago - 7 years 5 months ago #4097
by sakattack
Replied by sakattack on topic PHP 7 support
So, I went ahead and implemented the change myself. Can you take a look at the code and see if there's anything amiss? As far as I can tell it works just fine, but I may have forgotten something. Here is the code (before the html output which is trivial and so I do not post it)
<?php
require_once ('../../configuration.php');
$config=new JConfig;
$db_host= $config->host;
$db_user= $config->user;
$db_password=$config->password;
$db_database=$config->db;
$db_table= $config->dbprefix .'dataitems';
$currentUrl = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$escaped_link = htmlspecialchars($currentUrl, ENT_QUOTES, 'UTF-8');
$mysqli = new mysqli($db_host, $db_user, $db_password, $db_database);
if ($mysqli->connect_error) {
die('Connect Error (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error);
}
$mysqli->set_charset("utf8");
@$item = (int)$_REQUEST["item"];
if ( $item and is_numeric($item) ) {
$dbquery = $mysqli->query ("select sql_no_cache description,url,image,feed,title from ".$db_table." WHERE items_id = ".$item);
$product = $dbquery->fetch_array(MYSQLI_ASSOC);
} else {
$product=false;
}
if ($product && $product["url"]) {
$dbupdate = $mysqli->query ("UPDATE LOW_PRIORITY ".$db_table." SET hits = ( hits + 1 ) WHERE items_id = ".$item);
$url=str_replace('& amp;','&',$product["url"]);
} else {
$url='/';
}
?>
<?php
require_once ('../../configuration.php');
$config=new JConfig;
$db_host= $config->host;
$db_user= $config->user;
$db_password=$config->password;
$db_database=$config->db;
$db_table= $config->dbprefix .'dataitems';
$currentUrl = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$escaped_link = htmlspecialchars($currentUrl, ENT_QUOTES, 'UTF-8');
$mysqli = new mysqli($db_host, $db_user, $db_password, $db_database);
if ($mysqli->connect_error) {
die('Connect Error (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error);
}
$mysqli->set_charset("utf8");
@$item = (int)$_REQUEST["item"];
if ( $item and is_numeric($item) ) {
$dbquery = $mysqli->query ("select sql_no_cache description,url,image,feed,title from ".$db_table." WHERE items_id = ".$item);
$product = $dbquery->fetch_array(MYSQLI_ASSOC);
} else {
$product=false;
}
if ($product && $product["url"]) {
$dbupdate = $mysqli->query ("UPDATE LOW_PRIORITY ".$db_table." SET hits = ( hits + 1 ) WHERE items_id = ".$item);
$url=str_replace('& amp;','&',$product["url"]);
} else {
$url='/';
}
?>
Last edit: 7 years 5 months ago by sakattack.
Please Log in or Create an account to join the conversation.
7 years 5 months ago #4099
by bram
Replied by bram on topic PHP 7 support
Right,
php 7 removed the mysql connector, so you need to switch to mysqli.
I checked and updated the component for php7 but missed the clickout script. Will need to do that.
Code looks fine, it's easy enough to test whether or not it works.
Just wondering about the currentUrl and escaped_link, seems that you are not using them anywhere.
php 7 removed the mysql connector, so you need to switch to mysqli.
I checked and updated the component for php7 but missed the clickout script. Will need to do that.
Code looks fine, it's easy enough to test whether or not it works.
Just wondering about the currentUrl and escaped_link, seems that you are not using them anywhere.
Please Log in or Create an account to join the conversation.
7 years 5 months ago #4100
by sakattack
Replied by sakattack on topic PHP 7 support
I'm using the escaped_link later on in the html output. Thank you for taking the time to answer. You said you updated the component for php 7. When did this happen? Is there a new version of the component?
Please Log in or Create an account to join the conversation.
Time to create page: 0.241 seconds