Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/

Discussion in 'Desain Web dan Programming' started by Ichwantaufiq, 30 Jun 2013.

Thread Status:
Not open for further replies.
  1. Ichwantaufiq

    Ichwantaufiq New Member

    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/imgboxsc/public_html/affiliate.php on line 54

    ini apa saya disuruh mengganti parameter 0 menjadi satu pada file affiliate.php

    tpi saya rubahpun tetep aja muncul gitu.. mohon dicerahin boss
     
  2. Ichwantaufiq

    Ichwantaufiq New Member

    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    kode afiliate.php nya

    require_once('config.php');
    $dbconnect = new db();
    $dbconnect->connect();

    $configs = new configs();
    $configsarr = $configs->fetch();

    $login = new login();
    $login->page_protect();

    $lockedStatus = $configs->isLocked($_SESSION['user_id']);

    if(AFFILIATE_ENABLED == 1) {
    if(isset($_GET['aplly'])){
    $qCheck = "SELECT id FROM aff_users WHERE id_user = '{$_SESSION['user_id']}'";
    $qResult = mysql_query($qCheck);
    if($qResult && mysql_num_rows($qResult) == 0) {

    $qApply = "INSERT INTO aff_users (`id_user`, `payment_opt`, `payment_id`, `earnings`, `active`) VALUES ('{$_SESSION['user_id']}','1','','0','0')";
    $resultqApply = mysql_query($qApply);
    if($resultqApply) {
    header('Location: affiliate.php');
    exit();
    } else {
    echo mysql_error();
    die("Error creating your account");
    }

    } // END COUNTING AFF_USERS ROWS
    } // END GET APPLY


    $q = "
    SELECT aff_users.*, aff_payoptions.pname FROM aff_users
    LEFT JOIN aff_payoptions ON aff_users.payment_opt = aff_payoptions.id
    WHERE aff_users.id_user = '{$_SESSION['user_id']}'";
    $result = mysql_query($q);
    if(mysql_num_rows($result) > 0) { <============== ini yang kena warnong line 54
    $rowAffiliate = mysql_fetch_assoc($result);
    $affAcc = true;
    } else {
    $affAcc = false;
     
  3. Mylo Sepz

    Mylo Sepz Apprentice 2.0

    Messages:
    532
    Likes Received:
    59
    Trophy Points:
    28
    Biasanya kesalahan di
    PHP:
    $q "
    SELECT aff_users.*, aff_payoptions.pname FROM aff_users
    LEFT JOIN aff_payoptions ON aff_users.payment_opt = aff_payoptions.id
    WHERE aff_users.id_user = '
    {$_SESSION['user_id']}'";
    Itu karena terlalu banyak syarat sehingga mysql gak bisa jalankan query

    Coba
    PHP:
    $q "SELECT aff_users.*, aff_payoptions.pname FROM aff_users WHERE aff_users.id_user = '{$_SESSION['user_id']}'";
    Note: Sebelum di coba harap di backup dahulu
     
  4. MelMel

    MelMel Beginner 2.0

    Messages:
    26
    Likes Received:
    0
    Trophy Points:
    1
    Kk sudah coba mendebug querynya? Mysql_num_rows seharusnya return jumlah row data. Kalau dia return boolean, kemungkinan besar hasilnya FALSE, atau dengan kata lain query kk gagal.

    Oh iya, sebaiknya beralih ke PDO mysql, soalnya mysql class ini akan dihapus mulai php 5.5 keatas (ngga future-proof)
     
Loading...
Thread Status:
Not open for further replies.

Share This Page

Loading...