|  | 
	                
  
    | 
	 
        เกิด error แบบนี้แก้ยังไงได้บ้างคะ Warning: mysqli_query() expects parameter 1 to be mysqli, resource given in     |  
    |  |  
 
	
		|  |  |  |  |  
		|  |  | 
          
            | มันขึ้นแสดงตลอดเวลากดปุ่มเพื่อบันทึกลงในฐานข้อมูล Warning: mysqli_query() expects parameter 1 to be mysqli, resource given in C:\xampp\htdocs\subconinfo\user\save_subcon.php on line 26
 Warning: mysqli_query() expects parameter 1 to be mysqli, resource given in C:\xampp\htdocs\subconinfo\user\save_subcon.php on line 46
 
 นี้โค้ดเต็มค่ะช่วยดูให้หน่อยได้มั้ยคะ ขอบคุณมากๆค่ะ
 <?php
 //check if form is submitted
 if (isset($_POST['submit']))
 {
 include "config.php";
 $name = $_POST['fname'];
 $notel = $_POST['notel'];
 $nmasyarikat = $_POST['nmasya'];
 $nopendsya = $_POST['pendsya'];
 $lokasi1=implode(' ',$_POST['lokasi']);
 $skop1=implode(' ',$_POST['sk']);
 $nota = $_POST['nota'];
 $kmhr1=implode(' , ',$_POST['kmhr']);
 $filename = $_FILES['filename']['name'];
 //upload file
 if($filename != '')
 {
 $ext = pathinfo($filename, PATHINFO_EXTENSION);
 $allowed = ['pdf', 'txt', 'doc', 'docx', 'png', 'jpg', 'jpeg',  'gif', 'excel', 'mp4'];
 
 //check if file type is valid
 if (in_array($ext, $allowed))
 {
 // get last record id
 $sql = 'select max(id) as id from information';
 $query_sql = mysqli_query($link, $sql); <--- เกิดตรงนี้
 if (count($query_sql) > 0)
 {
 $row = mysqli_fetch_array($query_sql);
 $filename = ($row['id']+1) . '-' . $filename;
 }
 else
 $filename = '1' . '-' . $filename;
 //set target directory
 $path = 'uploads/';
 if (!is_dir($path)) {
 echo 'error';
 } else {
 move_uploaded_file($_FILES['filename']['tmp_name'],($path . $filename));
 }
 
 
 // insert file details into database
 $sql = "INSERT INTO information(id,name,notel,nmasyarikat,nopendsya,lokasi,skop,pekerja,kemahiran,document)
 VALUES(NULL,'$name','$notel','$nmasyarikat','$nopendsya','$lokasi1','$skop1','$kmhr1','$filename')";
 $query_sql=mysqli_query($link,$sql);  <--- เกิดตรงนี้
 if($query_sql){
 //noti after submit and go to main page
 echo "<script>
 window.location.href='subcon.php';
 alert('Matlumat anda telah disimpan. Terima Kasih');
 </script>";
 }
 else{
 echo mysqli_connect_error($link);
 echo'<script>alert("Failed To Insert")</script>';
 }
 }
 else
 {
 header("Location: subcon.php?st=error");
 }
 }
 else
 header("Location: subcon.php");
 }
 ?>
 
 
 
 Tag : PHP, MySQL, HTML, XAMPP
 
 
 |  
            |  |  
            | 
              
                |  |  |  |  
                |  | 
                    
                      | Date :
                          2023-03-05 09:17:35 | By :
                          Ruby | View :
                          843 | Reply :
                          3 |  |  |  
                |  |  |  |  |  
            |  |  
		            |  |  
		|  |  |  |  |  
  
    | 
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | มีแล้วนะคะ อยู่บันทัดที่5 include "config.php";
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2023-03-05 10:02:41 | By :
                            Ruby |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 |  |