mysql - PHP is updating instead of inserting -


i creating page user fill report , report inserted database have below php page supposed insert new values table reports, updating instead

<?php  include 'connectionfile.php' ;  $ref = $_post['ref'];  $title =$_post['titl'];  $type = $_post['type'];  $content = $_post['content']; session_start();  $sql = "insert reports (reference, title,id_type, content) values ('".$ref."', '".$title."', '". $type."','".$content."');";  $result =mysqli_query($con,$sql ); ?> 

is because id_type (primary key of table type) foreign key -in table report- of value 1 , 2?

because if insert id_type=1 example, id_report (primary key of table report) increments 1, same goes id_type=2

answer might clear,my knowledge in web development forgotten.

with sql-query provided, no update possible. can make update on duplicate key, not in query. please note, not have , should not specify value automatically setted parameter (auto_increment).


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -