Hosting Free - mysqli PDO bug for default php 7x

webmestudio
edited November 2017 in Bug/Issue Reports

hi admin i found mysqli pdo bug for PHP 7, below example code
Can you fix it? and why after i changed the php version, a php version does not change why? do i have to upgrade hosting

1. <?php
2. error_reporting(E_ALL);
3. 
4. $host = 'sql110.ezyro.com';
5. $user = 'ezyro_20892691';
6. $pass = 'social102';
7. $name = 'ezyro_20892691_webmestudio';
8. 
9. $db = new mysqli($host, $user, $pass, $name);
10. if($db->connect_error) {
11.     die('tidak terkoneksi ke database');
12. }
13. 
14. if($_SERVER['REQUEST_METHOD'] == 'POST') 
15. {
16.     //deklarasi
17.     $email = $_POST['mailverify'];
18. 
19.     if(filter_var($email, FILTER_VALIDATE_EMAIL)) {
20. 
21.         //cek di database
22.         $sql = $db->query("select * from subscriber where email = '$email' ");
23. 
24.         if($sql->num_rows == 1) 
25.         {
26.             $json = [
27.                 'error' => false,
28.                 'alert' => 'Email tersedia siap download',
29.                 'link_download' => 'http://google.com' //ganti dengan link download
30.             ];
31.         }
32.         else
33.         {
34.             $json = [
35.                 'error' => true,
36.                 'alert' => 'Maaf email tidak tersedia ',
37.                 'link_download' => null
38.             ];
39.         }
40.     }
41.     else 
42.     {
43.         $json = [
44.             'error' => true,
45.             'alert' => 'Email tidak valid'
46.         ];
47.     }
48. 
49.     echo json_encode($json);
50.         exit;
51. }
52. ?>

Comments

  • Admin
    edited November -1

    Please point out the bug and explain.
    You can change PHP Version from control panel easily, you do not need to upgrade for that.

  • webmestudio
    edited November 2017

    @Admin said:
    Please point out the bug and explain.
    You can change PHP Version from control panel easily, you do not need to upgrade for that.

    Example implementation, when I click download, but logic does not work on $ sql-> num_rows == 1, and always leads to notification error, while in the database, the data matches the data in the input earlier.