shruti A
asked on
update query is not working , giving Mariadb server version error
<?php
include ('db.php');
include ('header.php');
$id=$_GET['id'];
?>
<body>
<div class="container">
<div class="">
<div class="container-con">
<!-- end banner & menunav -->
<div class="container">
<div class="">
<div class="span12">
<div class="row-fluid">
<div class="span3"></div>
<div class="span6">
<div class="hero-unit-3">
<center>
<?php
$sql="select * from combo1 where id='$id'";
$query=mysqli_query($link,$sql)or die(mysqli_error($link));
$row=mysqli_fetch_array($query);
?>
<center>
<form class="form-horizontal" method="post" enctype="multipart/form-data">
<legend><h4>Edit</h4></legend>
<h4>UPDATE</h4>
<hr>
<div class="control-group">
<label class="control-label" for="inputColumn">COLUMN:</label>
<div class="controls">
<input type="text" name="column" required value=<?php echo $row['column']; ?>>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputType">TYPE:</label>
<div class="controls">
<input type="text" name="type" required value=<?php echo $row['type']; ?>>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputValue">VALUE:</label>
<div class="controls">
<input type="text" name="value" required value=<?php echo $row['value']; ?>>
</div>
</div>
<div class="control-group">
<div class="controls">
<button type="submit" name="update" class="btn btn-success" style="margin-right: 65px;" value="update">Save</button>
<a href="excombo.php" class="btn">Back</a>
</div>
</div>
</form>
</center>
<?php
$id=$_REQUEST['id'];
$result = mysqli_query($link,"SELECT * FROM combo1 WHERE id = '$id'");
$test = mysqli_fetch_array($result);
if (!$result)
{
die("Error: Data not found..");
}
$column= $test['column'];
$type= $test['type'];
$value= $test['value'];
if (isset($_POST['update'])) {
// $column=(isset( $_POST['column']));
$column = isset( $_POST['column']) ? $_POST['column']:" ";
//$type= (isset($_POST['type']));
$type = isset( $_POST['type']) ? $_POST['type']:" ";
//$value= (isset($_POST['value']));
$value = isset( $_POST['value']) ? $_POST['value']:" ";
echo $id;
echo $column;
echo $type;
echo $value;
mysqli_query($link,"UPDATE combo1 SET column = '$column' type = '$type' value ='$value' WHERE id ='$id'")
or die(mysqli_error($link));
header("Location:excombo.php");
}
?>
</center>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
it ia giving error like this
25col1INTAddressYou have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'column = 'col1' type = 'INT' value ='Address' WHERE id ='25'' at line 1
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.