piotrowski-s@hotmail.fr Posted April 4, 2016 Share Posted April 4, 2016 Hi, I did a custom page (a php file, a controller and a tpl). The tpl send data through a form and this data are used in the controller. I need to do a request and to look for values from database. If no result it return a mistake, and if a result it return the value of the database requested through an array then I use this value and display them back in the tpl. I did the following script but in return an error php I'm a novice I know what I want to do, but I don't know exactly how to do it. Deprecated: mysql_query(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /htdocs/controllers/front/AntiCounterfeitController.php on line 25Warning: mysql_query(): No such file or directory in /htdocs/controllers/front/AntiCounterfeitController.php on line 25Warning: mysql_query(): A link to the server could not be established in /htdocs/controllers/front/AntiCounterfeitController.php on line 25Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /htdocs/controllers/front/AntiCounterfeitController.php on line 26 And this is my controller code <?php /* Create a custom page in PrestaShop without CMS - CustomPageController class /* Read the detailed tutorial at https://iftakharhasan.wordpress.com/prestashop-create-a-custom-page-without-cms */ /* The classname here will be the name of the controller */ class AntiCounterfeitController extends FrontController { public function init() { $this->display_column_left = false; $this->display_column_right = false; parent::init(); } public function postProcess() { if (Tools::isSubmit('submitcounterfeit')) { $serial = Tools::getValue('serial'); $key = Tools::getValue('key'); } if(isset($_POST['submitcounterfeit'])){ $query = "SELECT * FROM `ps_counterfeit` WHERE `serial` = '{$serial}' AND `key` = '{$key}'"; $result = mysql_query($query); if(mysql_num_rows($result)==0){ $error = 1; $data = null; } elseif(mysql_num_rows($result)==1){ $error = 0; $data = mysql_fetch_assoc($result); } } } public function initContent() { parent::initContent(); $this->setTemplate(_PS_THEME_DIR_ . 'anti-counterfeit.tpl'); } } Anykind of help will be much appreciated. Link to comment Share on other sites More sharing options...
tuk66 Posted April 4, 2016 Share Posted April 4, 2016 Use Db::getInstance()->executeS instead of mysql_query. The similar for other mysql_* functions. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now