-1

I recently purchased a php script to use on my website however, there is no support for it, i attempted the installation and i received the error message:

mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home2/pulseman/public_html/install.php on line 16

Here is some of the script where i have to issue:

<?php

if (!defined("_WASD_")) exit;

$app = array('namespace'=>'phpmanga',
             'name'=>'PHP Manga');

if(C('app.installed') == '1'){
    $messageType = 'info';
    $message = 'Please delete "install.php" file in your root directory before launching your site';
}

if(isset($_POST['install']) && $_POST['install'] == '1'){


        $connect = mysql_connect($_POST['data']['DB_HOST'], $_POST['data']['DB_USER'], $_POST['data']['DB_PASSWORD']);
        if(!$connect){
            $messageType = 'danger';
            $message = 'Could not connect to the database you inputted in, please double check database detail and try again.';         
        }else{
            $db_selected = mysql_select_db($_POST['data']['DB_NAME'], $connect);
            if(!$db_selected){
                $messageType = 'danger';
                $message = 'Could not select the database "'.$_POST['data']['DB_NAME'].'"<br />That could be due to spelling errors in database name or that database doesn\'t exist please double check database detail and try again.'; 

I would to know to fix the issue or pointed in the direction, I am a beginner, i apologize in advance.

Mimex
  • 1
  • 1
    what is the script suposed to do? – szoszk Aug 01 '15 at 22:11
  • 3
    The reasons you [shouldn't use `mysql_*`](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php?rq=1) are many: the `mysql_*` functions are outdated, [deprecated](http://us3.php.net/manual/en/intro.mysql.php), and insecure. Use [`MySQLi`](http://us3.php.net/manual/en/book.mysqli.php) or [`PDO`](http://us3.php.net/manual/en/intro.pdo.php) instead. Unfortunately, you paid for obsolete software. You will have to rewrite all database interactions if you want to fix this. The simpler (but not good) solution is just to turn off error reporting to suppress the warning. – elixenide Aug 01 '15 at 22:15
  • 5
    I would complain whereever you have bought this. As @EdCottrell commented, this script is outdated and you shouldn't use it as mysql has to be considered insecure. – baao Aug 01 '15 at 22:16
  • its part of a greater script that allows me to manage and upload content here is a link to it http://codecanyon.net/item/php-manga-manga-reader-website-solution/10102963 – Mimex Aug 01 '15 at 22:17

2 Answers2

0

Try this --

Change:

mysql_connect($_POST['data']['DB_HOST'], $_POST['data']['DB_USER'], $_POST['data']['DB_PASSWORD']);  

To:

 mysqli_connect($_POST['data']['DB_HOST'], $_POST['data']['DB_USER'], $_POST['data']['DB_PASSWORD']);

And change:

mysql_select_db($_POST['data']['DB_NAME'], $connect);

To:

mysqli_select_db($connect, $_POST['data']['DB_NAME']);

I haven't tested this, so let me know if it still gives you errors. I would also recommending using PDO over mysqli, but that would require a lot more changes than using mysqli.

DiddleDot
  • 745
  • 5
  • 16
0

There are several possible solutions, all of them are painful:

  1. You can accept the fact that you have been screwed up and acknowledge your budgetary loss. This way you have lost money, but at least you save some time which you can use to write your own srcipt.

  2. You can go wherever you bought this deprecated code, and ask them for paying back your money. With this solution you might get back your money, but you lose time. And you have to write your own script.

  3. You can ignore the warnings and accept that your code is insecure and will be invalid PHP code when PHP no longer supports those functions.

  4. You can carefully fix all these problems by using mysqli functions instead, but then, nobody guarantees there are no other problems in the script. You might end up losing a lot of time to find newer problems in the script.

So you either fix the script, or write your own, or accept the shortcommings of the script. If I were you, I would write my own script, complain to the ones who gave you this script and if they do not want to be cooperative, then whenever you see someone wanting to buy something from them, tell them about your experience.

Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175