fekaduw Posted March 13, 2007 Share Posted March 13, 2007 hello everyone, i was trying to insert a data into mysql db but my system inserts a given data twice. i tried to sort out the problem but i faild. Here is the code that inserts the data: <?php require("../includes/dbconnection.php"); $vid=$_POST["id"]; $vname =$_POST["firmname"]; $vtype=$_POST["type"]; $vcategory=$_POST["category"]; $vsubcity=$_POST["subcity"]; $vkebele=$_POST["kebele"]; $vhouseno=$_POST["houseno"]; $vtel=$_POST["telephone"]; $vpobox=$_POST["pobox"]; $vfax=$_POST["fax"]; $vemail=$_POST["email"]; $vwebsite=$_POST["website"]; $vservices=$_POST["services"]; if(($vid=="")||($vid==0)) { $SQL="INSERT INTO tconsultant (name,type,category,subcity,kebele,houseno,tel,fax,email,website,services,pobox) values('".$vname."','".$vtype."','".$vcategory."','".$vsubcity."','".$vkebele."','".$vhouseno."','".$vtel."','".$vfax."','".$vemail."','".$vwebsite."','".$vservices."', '".$vpobox."')"; } else { $SQL="UPDATE tconsultant SET name='".$vname."',type='".$vtype."',category='".$vcategory."',subcity='".$vsubcity."',kebele='".$vkebele."',houseno='".$vhouseno."',tel='".$vtel."',pobox='".$vpobox."', fax='".$vfax."',email='".$vemail."',website='".$vwebsite."',services='".$vservices."' where id=".$vid; } mysql_query($SQL); header("Location: consultants.php"); exit(); ?> any help is highly appreciated Link to comment https://forums.phpfreaks.com/topic/42532-problem-in-inserting-data-into-mysql-db/ Share on other sites More sharing options...
Vikas Jayna Posted March 13, 2007 Share Posted March 13, 2007 Look OK! Whats the script consultants.php doing? Probably the second insert is happening inside this. Link to comment https://forums.phpfreaks.com/topic/42532-problem-in-inserting-data-into-mysql-db/#findComment-206364 Share on other sites More sharing options...
fekaduw Posted March 13, 2007 Author Share Posted March 13, 2007 consultants.php simply displays the data inserted in the previous page. i checked out that. there is no code that is related to insert or update. simply displaying the data(using select to retrieve the items) Link to comment https://forums.phpfreaks.com/topic/42532-problem-in-inserting-data-into-mysql-db/#findComment-206474 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.