2017-01-19 22 views
-3

ヘルプ:?これは私が取得警告である私

警告:はmysql_num_rows()はブール値が上/home/dweetcom/public_html/admin_kepuasan.phpに与えられ、パラメータ1は資源であることを期待ライン30

< ---ライン30 --->

if (mysqli_num_rows($result) > 0) { 

< --- admin_kepuasan.php --->

<?php 
require_once 'connection1.php'; 
?> 
<html> 
<link rel="stylesheet" type="text/css" href='https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css'/> 

<?php 

$sql="SELECT * FROM borang_kepuasan"; 
$result=mysqli_query($conn,$sql); 

echo "<table id='example' class='display' cellspacing='1' width='100%'>"; 
echo "<thead>"; 
echo "<tr>"; 
echo "<td>Soalan 1</td>"; 
echo "<td>Soalan 2</td>"; 
echo "<td>Soalan 3</td>"; 
echo "<td>Soalan 4</td>"; 
echo "<td>Soalan 5</td>"; 
echo "<td>Soalan 6</td>"; 
echo "<td>Soalan 7</td>"; 
echo "<td>  Nota/Testimoni  </td>"; 
echo "</tr>"; 
echo "</thead>"; 
echo "<tbody>"; 

if (mysqli_num_rows($result) > 0) { 
    while ($row = mysqli_fetch_assoc($result)) { 
     echo "<tr>"; 
     echo "<td>$row[soalan1]</td>"; 
     echo "<td>$row[soalan2]</td>"; 
     echo "<td>$row[soalan3]</td>"; 
     echo "<td>$row[soalan4]</td>"; 
     echo "<td>$row[soalan5]</td>"; 
     echo "<td>$row[soalan6]</td>"; 
     echo "<td>$row[soalan7]</td>"; 
     echo "<td>$row[nota]</td>"; 
     echo "</tr>"; 
    } 
} else { 
    echo "0 results"; 
} 

echo "</tbody>"; 
echo "</table>"; 
echo "<center>"; 
echo "<table>"; 
echo "<tr>"; 
echo "<td>"; 
    echo "<button style=height:30px width:80px value=Kembali onClick=location.href='admin1.php'>"; 
    echo "Kembali"; 
    echo "</button>"; 
echo "</td>"; 
echo "<td>"; 
    echo "<button style=height:30px width:80px value=Log Out onClick=location.href='logout.php'>"; 
    echo "Log Out"; 
    echo "</a>"; 
    echo "</button>"; 
echo "</center>"; 
?> 
</html> 
<script src='//code.jquery.com/jquery-1.12.4.js'></script> 
<script src='https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js'></script> 
<script> 
$('#example').DataTable(); 
</script> 

< --- connection1.php --->

<?php 
$servername = "localhost"; 
$username = "dweetcom"; 
$password = "***********"; 

// Create connection 
$conn = new mysqli($servername, $username, $password) ; 
if (mysqli_connect_errno()) { 
    echo "Failed to connect to MySQL: " . mysqli_connect_error(); 
} 

@mysqli_select_db("dweetcom_borang",$conn); 
?> 

< --- 153に警告:--->

mysql_query("INSERT INTO borang_kepuasan(soalan1, soalan2, soalan3, soalan4, soalan5, soalan6, soalan7 ,nota) VALUES 

< --- borang_kepuasan。 PHP --->

<html><head> 
<style> 
html 
{ 
font-family:Lucida Grande, sans-serif; 
color: rgba(158,4,22,0.91); 


} 

.container 
{ 
max-width:699px; 
height:86%; 
margin:0 auto; 

} 
header 
{ 
width:100%; 
background-image: url("pink1.jpg"); 

} 



.content 

{ 

    border: 0px solid; 
    padding: 20px; 
    width: 680px; 
    height: 168%; 
    background:#ffe6e6; 
} 

.last 
{ 
margin-right:0; 
} 

textarea 
{font-family:"Lucida Grande"; 
} 

.table{ 
    font-family: "Lucida Grande"; 

    border-collapse: collapse; 
    width: 150%; 
} 
.td1{background-color: #dddddd; 
font-family: "Lucida Grande"; 
font-size:16px; 
} 


.table1 { 
    font-family: "Lucida Grande"; 
    font-size:16px; 
    border-collapse: collapse; 
    width: 100%; 
} 

td, th { 
    border: 1px solid #dddddd; 
    text-align: left; 
    padding: 8px; 
} 

tr:nth-child(even) { 
    background-color: #dddddd; 
} 


p{ 
    font-family: "Lucida Grande"; 
    color: rgba(158,4,22,0.91); 

} 

button { 
    background-color: white; 
    color: black; 
    border: 3px solid #e7e7e7; 
    border-radius: 20px; 
    width:150px; 
    height:5%; 

} 
.hr { 
color: rgba(158,4,22,0.91); 
} 

textarea { 
font-family: "Lucida Grande"; 
    font-size:16px; 
} 
    .footer 
{ p:2%} 
button:hover {background-color: #e7e7e7;} 

@media(max-width: 400px) { 
    .col, nav ul li { 

    width:95%; 
    clear:both; 
    } 

} 
</style> 
<br/><br/><center><img src="logo_Dweet (2).588.png" width="400" /></center> 
</head> 

<body background="pink1.jpg"><br/> 

<?php 
include("connection1.php"); 
if(isset($_POST['hantar'])) 
{ 
// print_r($_POST); exit; 
    $soalan1 = $_POST['soalan1']; 
    $soalan2 = $_POST['soalan2']; 
    $soalan3 = $_POST['soalan3']; 
    $soalan4 = $_POST['soalan4']; 
    $soalan5 = $_POST['soalan5']; 
    $soalan6 = $_POST['soalan6']; 
    $soalan7 = $_POST['soalan7']; 
    $nota = $_POST['nota']; 


    if($soalan1==" "||$soalan2==" "||$soalan3==" "||$soalan4==" "||$soalan5==" "||$soalan6==" " || $soalan7==" "||$nota==" ") 
    { 

    echo "<center>"; 
    echo "<font size=6 face=Lucida Grande>"; 
    echo "<b>HARAP MAAF!</b>"; 
    echo "<br/>"; 
    echo "Terdapat maklumat yang belum dilengkapkan."; 
    echo "<br/>"; 
    echo "Sila lengkapkan maklumat anda."; 
    echo "<br/>"; 
    echo "<br/>"; 
    echo "<button style=height:50px width:20px color:#000000; value=Kembali onClick=history.go(-1);return true;>"; 
    echo "Kembali"; 
    echo "</button>"; 
    echo "</font>"; 
    echo "</center>"; 
    } 
    else 
    { 
    mysql_query("INSERT INTO borang_kepuasan(soalan1, soalan2, soalan3, soalan4, soalan5, soalan6, soalan7 ,nota) VALUES ('$soalan1','$soalan2','$soalan3','$soalan4','$soalan5','$soalan6','$soalan7','$nota')", $conn) 
    or die ("Tidak boleh mencapai masuk queri."); 

    echo "<center>"; 
    echo "<font size=5 face=Lucida Grande>"; 
    echo "<b>TAHNIAH!</b>"; 
    echo "<br/>"; 
    echo "Borang Survay anda telah berjaya dihantar . Terima Kasih atas kerjasama yang diberikan"; 
    echo "<br/>"; 
    echo "<br/>"; 
    echo "<button style=height:50px width:20px value=Kembali onClick=location.href='borang_kepuasan.php'>"; 
    echo "Kembali"; 
    echo "</button>"; 
    echo "</font>"; 
    echo "</center>"; 
    } 
} 
else 
{ 
    ?> 

<div class="container"> 

    <section class="content_area"> 
    <div class="content"> 



<center><br/> 
    <p><b><font size="+3" face="verdana">Borang Survay Kepuasan Pelanggan</font></b></p> 


    <p>Sila tandakan nombor yang sepadan dengan tahap persetujuan anda. </p> 
    <table> 
    <tr> 
     <td class="td1">1 </td> 
     <td> Amat Tidak Setuju </td> 
     <td class="td1"> 2 </td> 
     <td> Tidak Setuju </td> 
     <td class="td1"> 3 </td> 
     <td> Kurang Setuju </td> 
     <td class="td1"> 4 </td> 
     <td> Setuju </td> 
     <td class="td1"> 5 </td> 
     <td> Sangat Setuju </td> 
    </tr> 
</table> 

<hr> 
    <form name="form1" method="post" action=""><br/> 
<table class="table1"> 
    <tr> 
    <th>Bil</th> 
    <th>Perkara</th> 
    <th>1</th> 
    <th>2</th> 
    <th>3</th> 
    <th>4</th> 
    <th>5</th> 
    </tr> 

    <tr> 
     <td>1 </td> 
     <td> Akaun Instagram & Facebook Dweet sangat berinformasi & membantu saya. </td> 
     <td> <input type="radio" name="soalan1" value="Amat tak setuju " > </td> 
     <td> <input type="radio" name="soalan1" value="Tidak setuju " > </td> 
     <td> <input type="radio" name="soalan1" value="Kurang setuju " > </td> 
     <td> <input type="radio" name="soalan1" value="Setuju " > </td> 
     <td> <input type="radio" name="soalan1" value="Sangat setuju " > </td> 
    </tr> 

    <tr> 
     <td>2</td> 
     <td> Saya rasa team Dweet menghargai saya sebagai pelanggan. </td> 
     <td> <input type="radio" name="soalan2" value="Amat tak setuju " > </td> 
     <td> <input type="radio" name="soalan2" value="Tidak setuju " > </td> 
     <td> <input type="radio" name="soalan2" value="Kurang setuju " > </td> 
     <td> <input type="radio" name="soalan2" value="Setuju " > </td> 
     <td> <input type="radio" name="soalan2" value="Sangat setuju " > </td> 
    </tr> 

    <tr> 
     <td>3</td> 
     <td> Saya tidak mengalami masalah ketika dalam proses pesanan. </td> 
     <td> <input type="radio" name="soalan3" value="Amat tak setuju " > </td> 
     <td> <input type="radio" name="soalan3" value="Tidak setuju " > </td> 
     <td> <input type="radio" name="soalan3" value="Kurang setuju " > </td> 
     <td> <input type="radio" name="soalan3" value="Setuju " > </td> 
     <td> <input type="radio" name="soalan3" value="Sangat setuju " > </td> 
    </tr> 

<tr> 
     <td>4</td> 
     <td> Tempahan saya siap pada hari yang dijanjikan. </td> 
     <td> <input type="radio" name="soalan4" value="Amat tak setuju " > </td> 
     <td> <input type="radio" name="soalan4" value="Tidak setuju " > </td> 
     <td> <input type="radio" name="soalan4" value="Kurang setuju " > </td> 
     <td> <input type="radio" name="soalan4" value="Setuju " > </td> 
     <td> <input type="radio" name="soalan4" value="Sangat setuju " > </td> 
    </tr> 

    <tr> 
     <td>5</td> 
     <td> Pesanan saya siap seperti yang telah saya tempah. </td> 
     <td> <input type="radio" name="soalan5" value="Amat tak setuju " > </td> 
     <td> <input type="radio" name="soalan5" value="Tidak setuju " > </td> 
     <td> <input type="radio" name="soalan5" value="Kurang setuju " > </td> 
     <td> <input type="radio" name="soalan5" value="Setuju " > </td> 
     <td> <input type="radio" name="soalan5" value="Sangat setuju " > </td> 
    </tr> 

    <tr> 
     <td>6</td> 
     <td> Saya akan mengesyorkan Dweet kepada rakan-rakan dan ahli keluarga saya. </td> 
     <td> <input type="radio" name="soalan6" value="Amat tak setuju " > </td> 
     <td> <input type="radio" name="soalan6" value="Tidak setuju " > </td> 
     <td> <input type="radio" name="soalan6" value="Kurang setuju " > </td> 
     <td> <input type="radio" name="soalan6" value="Setuju " > </td> 
     <td> <input type="radio" name="soalan6" value="Sangat setuju " > </td> 
    </tr> 

<tr> 
     <td>7</td> 
     <td> Secara keseluruhan,saya sangat berpuas hati menjadi pelanggan Dweet. </td> 
     <td> <input type="radio" name="soalan7" value="Amat tak setuju " > </td> 
     <td> <input type="radio" name="soalan7" value="Tidak setuju " > </td> 
     <td> <input type="radio" name="soalan7" value="Kurang setuju " > </td> 
     <td> <input type="radio" name="soalan7" value="Setuju " > </td> 
     <td> <input type="radio" name="soalan7" value="Sangat setuju " > </td> 
    </tr> 

</table> 
     <p> Nota/Testimoni <br/> 
     <textarea name="nota" rows="7" cols="70" > </textarea> 
     </p> 





      <p>&nbsp;</p> 
       <button type="button" value="Laman Utama" onClick="location.href='index.html'" >Laman Utama </button> 
       <button type="submit" name="hantar" value="Hantar Borang">Hantar Borang</button> 


<p><h3>Terima Kasih</h3> 
Kerana meluangkan sedikit masa menjawab soalan survey ini. <br/> 
Ianya sangat membantu kami untuk membaiki lagi servis syarikat.<br/> 
Anda sangat Ohsem!</p> 

     </center> 

</section> 
</form> 
<br/> 
<div id="footer"> 
    <center><p><b>DWEET CARD</b><br/><font size="2">56-1,Jalan 8/36, Seri Bangi,Seksyen 8, 43650 Bandar Baru Bangi, Selangor<br/>Tel: +603 8912 3812 Whatsapp: +6017 3424341 Laman Web: www.thinkd.com.my</font></p> 
    <br/><br/></div> 
    </center> 
</div> 
    <?php 
} 
?> 

</body> 
</html> 

答えて

0

mysql_queryはboolean falを返すことができますSQLエラーが

if($result === false) { 
     var_dump(mysql_error()); 
    } 
    else { 
     if (mysqli_num_rows($result) > 0) { 
      if (mysqli_num_rows($result) > 0) { 
       while ($row = mysqli_fetch_assoc($result)) { 
        echo "<tr>"; 
        echo "<td>$row[soalan1]</td>"; 
        echo "<td>$row[soalan2]</td>"; 
        echo "<td>$row[soalan3]</td>"; 
        echo "<td>$row[soalan4]</td>"; 
        echo "<td>$row[soalan5]</td>"; 
        echo "<td>$row[soalan6]</td>"; 
        echo "<td>$row[soalan7]</td>"; 
        echo "<td>$row[nota]</td>"; 
        echo "</tr>"; 
       } 
      } else { 
       echo "0 results"; 
      } 
     } 
    } 

を起こればそれ自体もあなただけにライン

if (mysqli_num_rows($result) > 0) { 

を変更することができます。

if ($result !== false && mysqli_num_rows($result) > 0) { 

しかし、あなたは何が悪かったのか確認するためにMySQLのエラーをのvar_dumpする必要がありますあなたのお問い合わせあり

PSこれは百万回答えられました

+0

私はそれを置くべきですか?申し訳ありませんが、私はこのPHPの主題では良くありません。 – Emma

+0

私はunswitchを編集しました。 if(mysqli_num_rows($ result)> 0){私があなたに与えたコードの内容で置き換える必要があります。 –

+0

ありがとう。もう警告はありませんが、私のページの "bool(false)"に何かが出てきます – Emma

関連する問題