I make page as follows:
<?php
$host="localhost";
$user="root";
$password="";
$database="student";
$link= mysqli_connect($host,$user,$password,$database);
if(isset($_POST['btnsave']))
{
$reg=$_POST['reg'];
$name=$_POST['name'];
$trade=$_POST['trade'];
$college=$_POST['college'];
$query="CALL insert($reg,'$name','$trade',$college)";
$res= mysqli_query($link,$query);
if(mysqli_affected_rows($link)==1)
{
echo 'Data Saved';
}
else
{
print_r(mysqli_error($link));
}
}
?>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<form name="form" action="stored_procedure.php" method="post">
<table border="2">
<tr>
<td>Reg No</td>
<td><input type="text" name="reg">
</tr>
<tr>
<td>Name</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td>Trade</td>
<td><input type="text" name="trade">
</tr>
<tr>
<td>College</td>
<td><input type="text" name="college"/></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" name="btnsave" value="Save"/>
<input type="submit" name="btnupdate" value="Update"/>
<input type="submit" name="btndel" value="Delete"/>
</td>
</tr>
</table>
</form>
</body>
</html>
Then create procedure like this:
begin
insert student1 values(reg,name,trade,college);
end
After submitting the form it gives the following error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near
'insert(6546,'dffgd','teredr',432)' at line 1
I do everything but unable to fix this, please help me with this error.