Почему я получаю предупреждение в своем PHP?
Привет, я создал свой собственный php-файл. и когда я запускаю его, я получаю предупреждение. честно говоря, я не очень хорошо разбираюсь в этой теме php.Помоги мне найти ошибку
&ЛТ;---предупреждение я вам ---&ГТ;
Предупреждение: mysqli_query () ожидает, что параметр 1 будет mysqli, строкой, заданной в /home/dweetcom/public_html/borang_kepuasan.php на линии 153
< - - - строка 153- - - >
mysqli_query($conn,"INSERT INTO borang_kepuasan(soalan1, soalan2, soalan3, soalan4, soalan5, soalan6, soalan7 ,nota) VALUES ('$soalan1','$soalan2','$soalan3','$soalan4','$soalan5','$soalan6','$soalan7','$nota')", $conn)
Что я уже пробовал:
&ЛТ;--- borang_kepuasan.РНР---&ГТ;
<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 "HARAP MAAF!"; 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 { mysqli_query($conn,"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 "TAHNIAH!"; 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><font size="+3" face="verdana">Borang Survay Kepuasan Pelanggan</font></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> </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>DWEET CARD<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>
&ЛТ;---connection1.РНР---&ГТ;
<?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); ?>
NotPolitcallyCorrect
Как вы думаете, может быть, это потому, что вы проходите $conn дважды?
Emma96
Я удалил один $conn, и больше нет никаких предупреждений...но вдруг он вышел и сказал мне, что мой запрос не может быть вставлен. Значит ли это, что моя база данных-это проблема?
NotPolitcallyCorrect
Нет, это означает, что ваш запрос имеет проблему.