Warning: mysqli::query(): Empty query in C:\xampp\htdocs\admin\setswim.php on line 13 -


i tried update datas form in edit1.php setswim.php gives error : warning: mysqli::query(): empty query in c:\xampp\htdocs\admin\setswim.php on line 13

edit1.php

<html>  <body>      <center>    <?php     $d=$_get['id'];          include "includes/db.php";   if (mysqli_connect_errno())     {     echo "failed connect mysql: " . mysqli_connect_error();     }                           if ($result = $con->query("select * students student_number='".$d."'"))                          {                                  if ($result->num_rows > 0)                                  {                                             while ($row = $result->fetch_object())                                          {                                                         $number= $row->student_number;                                         												$n= $row->student_name;  												$d= $row->student_last;  												$a= $row->id_student;  										    	$b= $row->student_address;  												$c= $row->student_collage;  												$d= $row->student_datebirth;  												$price= $row->student_email ;                                            }                                  }                                  else                                  {                                          echo "no results display!";                                  }                          }  ?>  <html>  <body ><center>  <form action="setswim.php?id='"<?php echo $d;?>"' method="post" enctype="multipart/form-data">  <br><br><br><font color="red">  number: <input type="text" name="student_number" value="<?php echo $number;?>"> <br>  student_name: <input type="text" name="student_name" value="<?php echo $n;?>"> <br>  student_last: <input type="text" name="student_last" value="<?php echo"$d";?>"> <br>     id student: <input type="text" name="id_student" value="<?php echo $a;?>"> <br>     student address: <input type="text" name="student_address" value="<?php echo $b;?>"> <br>     student collage: <input type="text" name="student_collage" value="<?php echo $c;?>"> <br>     birthday: <input type="text" name="student_datebirth" value="<?php echo $d;?>"> <br>     student_email: <input type="text" name="student_email" value="<?php echo"$price";?>">     <br>         <br><br><br>        <br><input type="submit" name="submit" value="submit">  </form>  </center>  </font>    </center>    <?php include("adding.php"); ?>  </body>  </html>

and setswim.php

    <?php  	include "includes/db.php";  	                 $checklogin = mysqli_query($con,"select * `students`");      ?>  <?php                 if(isset($_post['submit'])) {            $sql=mysqli_query($con,"update students set student_number='".$_post['student_number']."',student_name='".$_post['student_name']."',student_last='".$_post['student_last']."',id_student='".$_post['id_student']."',student_address='".$_post['student_address']."',student_collage='".$_post['student_collage']."',student_datebirth='".$_post['student_datebirth']."',student_email='".$_post['student_email']."'");         //   $result = mysqli_query($con,$sql);  		  $result = $con->query($sql);    if (!$result) {      mysqli_error($con)."[ $sql]";  }  }    		   ?>         

<?php       include "includes/db.php";   // check connection   if (mysqli_connect_errno())     {     echo "failed connect mysql: " . mysqli_connect_error();     }      if ($result = $con->query("select * students "))                          {                                  if ($result->num_rows > 0)                                  {     								    echo "<table border='1' cellpadding='11'>";                                          echo " <tr> <th><font color=green size=3>number of student</font></th><th><font color=red size=5>name</font></th>  <th><font color=red size=5>last name</font></th> <th><font color=red size=5>id student</font></th> <th><font color=red size=5>emaill</font></th><th><font color=red size=5>address</font></th><th><font color=red size=5>collage</font></th><th><font color=blue size=5>date birth</font></th><th><font color=red size=5>edit</font></th><th><font color=red size=5>delete</font></th> </tr>";                                          while ($row = $result->fetch_object())                                          {                                                  echo "<tr>";                                                                                                   //echo "<td>" . $row->id. "</td>";<th>id</th>                                                 echo "<td style='test-align:center;'><small><strong>" . $row->student_number . "</small></strong></td>";  												echo "<td style='test-align:center;'><small>" . $row->student_name . "</small></td>";  												echo "<td style='test-align:center;'><small>" . $row->student_last . "</small></td>";                                                 echo "<td style='test-align:center;'><strong>id:</strong><small> ".$row->id_student. "</small></td>";  												echo "<td style='test-align:center;'><small>" . $row->student_email . "</small></td>";  												echo "<td style='test-align:center;' ><small>" . $row->student_address. "</small></td>";  														echo "<td style='test-align:center;' ><small>" . $row->student_collage. "</small></td>";  														echo "<td style='test-align:center;'><small>" .$row->student_datebirth."</small></td>";                                                  echo "<td><a href='edit1.php?id=" . $row->student_number . "'>edit</a></td>";                                                  echo "<td><a href='delswim.php?id=" . $row->student_number . "'>delete</a></td></small></small>";                                                  echo "</tr>";                                          }                                                                                    echo "</table>";                                  }                                  else                                  {                                          echo "no results display!";                                  }                          }                          else                          {                                  echo "error: " . $con->error;                          }                          $con->close();                                     				?>  				  			  </center>

error: warning: mysqli::query(): empty query in c:\xampp\htdocs\admin\setswim.php on line 13

the issue here

$sql = mysqli_query($con, "update students ..."); $result = $con->query($sql); 

a mysql result stored in $sql , used in query(), takes string.

only needs be

$result = mysqli_query($con, "update students ..."); 

or

$result = $con->query("update students ..."); 

but not both. use $con->query();


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -