Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: PHP Tidak Bisa Menampilkan Database SQL
http://idws.in/342674

  1. #1

    Join Date
    Sep 2010
    Location
    tegal
    Posts
    52
    Thank(s)
    0/45
    Rep Power
    0

    Default PHP Tidak Bisa Menampilkan Database SQL

    Code:
    dialogkotakmasuk.php
    <?php
    <?php
    include "cek.php";
    $namauser = $_SESSION['namauser'];
    include "conn.php";
    $query = "SELECT * FROM 'mail' WHERE To = '$namauser'";
    $hasil = mysql_query($query);
    $row = mysql_fetch_array($hasil);
    echo "
    <body>
    <html>
    <table border='1'>
    <tr>
    <td>Pengirim</td>
    <td>Subject</td>
    <td>Pesan</td>
    ";
    $j=0;
    while ($row) {
    echo "<tr>
    <td>".$row['From']."</td>
    <td>".$row['Subject']."</td>
    <td>".$row['Pesan']."</td>
    </tr>";
    $j++;
    }
    echo "</table>
    </body>
    </html>";
    ?>



    Jadi maksudnya isi database yang mau ditampilkan yang To = $Username


    mohon pencerahannya
    Reply With Quote Reply With Quote

  2. #2

    Join Date
    Feb 2010
    Location
    denpasar
    Posts
    52
    Thank(s)
    0/0
    Rep Power
    0

    Default

    wah ga ada yg coment nih
    Reply With Quote Reply With Quote

  3. #3

    Join Date
    Mar 2012
    Location
    Jakarta
    Posts
    25
    Thank(s)
    0/3
    Rep Power
    0

    Default

    keknya hasil querynya ga seperti yg diharapkan deh gan, error messagenya kan bilang tuh klo input mysql_fetch_array (dalam hal ini variabel $hasil) tipe datanya justru boolean
    Reply With Quote Reply With Quote

  4. #4

    Join Date
    Aug 2009
    Location
    Unknown
    Posts
    116
    Thank(s)
    0/33
    Rep Power
    0

    Default

    Mungkin bisa coba sintak ini:
    $con = mysql_connect("localhost", "username", "password");

    $query = "SELECT * FROM 'mail' WHERE To = '$namauser'";
    $hasil = mysql_query($query,$con);
    $row = mysql_fetch_array($hasil);

    Semoga membantu.
    Reply With Quote Reply With Quote

  5. #5

    Join Date
    Jan 2012
    Location
    jakarta
    Posts
    437
    Thank(s)
    0/1,142
    Rep Power
    0

    Default

    well,,entah apa yang ente bikin di cek.php sama conn.php
    tapi karena masalahnya adalah mysql_fetch_array() expects parameter 1 to be resource, boolean given,,
    gw fokus di sini aja ya...
    ini source code lu yang gw modif...

    <?php
    //include "cek.php";
    $con = mysql_connect("localhost", "root", "");
    mysql_select_db("test", $con);
    //$namauser = $_SESSION['namauser'];
    //include "conn.php";
    $query = "SELECT * FROM mail"; // WHERE To = '$namauser'";
    $hasil = mysql_query($query)or die(mysql_error()); //hendaknya memakai or die kalo mengeksekusi query...

    echo "
    <body>
    <html>
    <table border='1'>
    <tr>
    <td>Pengirim</td>
    <td>Subject</td>
    <td>Pesan</td>
    ";
    $j=0;
    while ($row = mysql_fetch_array($hasil)) {
    echo "<tr>
    <td>".$row['From']."</td>
    <td>".$row['Subject']."</td>
    <td>".$row['Pesan']."</td>
    </tr>";
    $j++;
    }
    echo "</table>
    </body>
    </html>";
    ?>
    Reply With Quote Reply With Quote

  6. #6

    Join Date
    Oct 2011
    Location
    jakarta
    Posts
    53
    Thank(s)
    0/1
    Rep Power
    0

    Default

    coba di echo $querynya trus string nya di copy ke php myadmin liat errornya apa , biasanya mysql_fetch_array() expects parameter 1 to be resource, boolean given, itu error sql atau koneksi databasenya
    Reply With Quote Reply With Quote

  7. #7

    Join Date
    Aug 2009
    Location
    jakarta
    Posts
    13
    Thank(s)
    0/0
    Rep Power
    0

    Default

    coba liat table mailnya dan isi table yg udah dicoba isi.
    To nya berdasarkan username aja ya ... nga pake id user.
    Reply With Quote Reply With Quote

  8. #8

    Join Date
    Feb 2009
    Location
    >>Secret Room<<
    Posts
    402
    Thank(s)
    0/4,031
    Rep Power
    0

    Default

    coba dari baris variable $row kebawah diganti menjadi spt ini :

    Show code


    PHP Code:
    $row mysql_num_rows($query);
    if(
    $row>0) {
    echo 
    "
    <body>
    <html>
    <table border='1'>
    <tr>
    <td>Pengirim</td>
    <td>Subject</td>
    <td>Pesan</td>
    "
    ;

    while (
    $data=mysql_fetch_array($query)) {
    echo 
    "<tr>
    <td>"
    .$data['From']."</td>
    <td>"
    .$data['Subject']."</td>
    <td>"
    .$data['Pesan']."</td>
    </tr>"
    ;

    }
    echo 
    "</table>
    </body>
    </html>"
    ;

    Reply With Quote Reply With Quote

  9. #9

    Join Date
    May 2010
    Location
    Fuuto
    Posts
    294
    Thank(s)
    0/1,018
    Rep Power
    0

    Default

    coba bantu, :)
    Code:
    dialogkotakmasuk.php
    
    <html>
    <body>
    
    <table border='1'>
    <tr>
    <td>Pengirim</td>
    <td>Subject</td>
    <td>Pesan</td>
    </tr>
    
    <?php
    include "cek.php"; //gw anggep udah bener
    $namauser = $_SESSION['namauser'];
    
    include "conn.php"; //gw anggep udah bener
    
    $query = "SELECT * FROM 'mail' WHERE To = '$namauser'";
    $hasil = mysql_query($query);
    while($row = mysql_fetch_array($hasil)){
    
    echo "
    <tr>
    <td>".$row['From']."</td>
    <td>".$row['Subject']."</td>
    <td>".$row['Pesan']."</td>
    </tr>
    ";
    
    }
    
    ?>
    </table>
    </body>
    </html>
    Reply With Quote Reply With Quote

  10. #10

    Join Date
    Aug 2010
    Location
    Bjm_Bungas
    Posts
    321
    Thank(s)
    0/3,718
    Rep Power
    0

    Default

    syntax sql nya salah tuh...
    coba "SELECT * FROM `mail` WHERE `To` = '$namauser'" //perhatikan tanda pertik.. pastikan di query sql phpmyadmin berhasil.. baru terapkan didalam script.. tt
    sekedar saran aja sih..... semoga membantu..
    Reply With Quote Reply With Quote

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Indowebster is proudly powered by PT. Gudang Data Indonesia