Hassan Ali Hashmi Hassan Ali Hashmi - 2 days ago 4
MySQL Question

MySQL server version for the right syntax to use near 'FROM user' at line 1

I get the error:

MySQL server version for the right syntax to use near 'FROM user' at line 1


How can I resolve this?

PHP:

<?php
session_start();
include ('dbconnect.php');

$sqql = "SELECT FROM user";
$query = mysqli_query($conn,$sqql) or die("Error: ".mysqli_error($conn));;

while($row = mysqli_fetch_array($query)) {
$id = $row['user_id'];
}
if(isset($_POST['submit'])) {
$name = $_POST['name'];
$desp = $_POST['desp'];
$date = date('Y-m-d H:i:s');
$sql = "INSERT INTO groups(user_id,name,desp,date) VALUES('$id','$name','$desp','$date')";

mysqli_query($conn,$sql);
}
mysqli_close($conn);
?>


HTML:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="Dashboard">
<meta name="keyword" content="Dashboard, Bootstrap, Admin, Template, Theme, Responsive, Fluid, Retina">

<title>DASHGUM - Bootstrap Admin Template</title>

<!-- Bootstrap core CSS -->
<link href="assets/css/bootstrap.css" rel="stylesheet">
<!--external css-->
<link href="assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="assets/js/bootstrap-datepicker/css/datepicker.css" />
<link rel="stylesheet" type="text/css" href="assets/js/bootstrap-daterangepicker/daterangepicker.css" />

<!-- Custom styles for this template -->
<link href="assets/css/style.css" rel="stylesheet">
<link href="assets/css/style-responsive.css" rel="stylesheet">

<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>

<?php include('sidebar.php'); ?>
<!-- **********************************************************************************************************************************************************
MAIN CONTENT
*********************************************************************************************************************************************************** -->
<!--main content start-->
<section id="main-content">
<section class="wrapper">
<h3><i class="fa fa-angle-right"></i> Vogue Productions</h3>

<!-- BASIC FORM ELELEMNTS -->
<div class="row mt">
<div class="col-lg-12">
<div class="form-panel">
<h4 class="mb"><i class="fa fa-angle-right"></i> Group</h4>
<form class="form-horizontal style-form" method="post">
<div class="form-group">
<label class="col-sm-2 col-sm-2 control-label">Name</label>
<div class="col-sm-10">
<input type="name" class="form-control" name="name">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 col-sm-2 control-label">Description</label>
<div class="col-sm-10">
<input type="desp" class="form-control" name="desp">
</div>
<div class="col-sm-10">
<Center><input type="submit" name="submit"></center>
</div>
</div>
</div>
</div>
</div><!-- /row -->

</section><! --/wrapper -->
</section><!-- /MAIN CONTENT -->

<!--main content end-->
<!--footer start-->
<footer class="site-footer">
<div class="text-center">
2014 - Alvarez.is
<a href="form_component.html#" class="go-top">
<i class="fa fa-angle-up"></i>
</a>
</div>
</footer>
<!--footer end-->
</section>

<!-- js placed at the end of the document so the pages load faster -->
<script src="assets/js/jquery.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script class="include" type="text/javascript" src="assets/js/jquery.dcjqaccordion.2.7.js"></script>
<script src="assets/js/jquery.scrollTo.min.js"></script>
<script src="assets/js/jquery.nicescroll.js" type="text/javascript"></script>
<!--common script for all pages-->
<script src="assets/js/common-scripts.js"></script>
<!--script for this page-->
<script src="assets/js/jquery-ui-1.9.2.custom.min.js"></script>
<!--custom switch-->
<script src="assets/js/bootstrap-switch.js"></script>
<!--custom tagsinput-->
<script src="assets/js/jquery.tagsinput.js"></script>
<!--custom checkbox & radio-->
<script type="text/javascript" src="assets/js/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="assets/js/bootstrap-daterangepicker/date.js"></script>
<script type="text/javascript" src="assets/js/bootstrap-daterangepicker/daterangepicker.js"></script>
<script type="text/javascript" src="assets/js/bootstrap-inputmask/bootstrap-inputmask.min.js"></script>
<script src="assets/js/form-component.js"></script>

<script>
//custom select box
$(function(){
$('select.styled').customSelect();
});
</script>

</body>
</html>

Answer

I have fixed the code. It's now working fine:

$sqql = "SELECT * FROM `users`";
Comments