cnagra Posted April 17, 2006 Share Posted April 17, 2006 hi,please can someone help me, im new to php and have to create a stock control systemi been trying to add data to mysql database through php. i am having trouble with adding to the database when there is multiple fields. everything is fine when the database has one field, but if it has more than one, no data is added to it, not even the workinf original field. i dont know why...can someone help?my form html - for when there is one field<form name="form" method="post" action="add_workin.php"> Name: <input type="text" name="name"><br><input type="Submit"></form>my php code for one field<?phpmysql_pconnect('localhost');mysql_select_db('test2');mysql_query("insert into test values ('$name')");?>my html for 2 fields....(NOTHING GETS ADDED not even the working field)<form name="form" method="post" action="add_workin.php"> Name: <input type="text" name="name"><br>Category: <input type="text" category="name"><br><input type="Submit"></form>my php code for two fields<?phpmysql_pconnect('localhost');mysql_select_db('test2');mysql_query("insert into test values ('$name')");mysql_query("insert into test values ('$category')");?>please help...thanks Quote Link to comment Share on other sites More sharing options...
litebearer Posted April 17, 2006 Share Posted April 17, 2006 Have a look at this tutorial.[a href=\"http://www.createafreewebsite.net/phpmysql/insert.html\" target=\"_blank\"]http://www.createafreewebsite.net/phpmysql/insert.html[/a]Note a couple of things - when you have more than 1 field in a database table you need to tell it which field is to receive the information --- to keep related data together enter them in to the database at the same time..Lite... Quote Link to comment Share on other sites More sharing options...
cnagra Posted April 17, 2006 Author Share Posted April 17, 2006 [!--quoteo(post=365426:date=Apr 16 2006, 09:13 PM:name=litebearer)--][div class=\'quotetop\']QUOTE(litebearer @ Apr 16 2006, 09:13 PM) [snapback]365426[/snapback][/div][div class=\'quotemain\'][!--quotec--]Have a look at this tutorial.[a href=\"http://www.createafreewebsite.net/phpmysql/insert.html\" target=\"_blank\"]http://www.createafreewebsite.net/phpmysql/insert.html[/a]Note a couple of things - when you have more than 1 field in a database table you need to tell it which field is to receive the information --- to keep related data together enter them in to the database at the same time..Lite...[/quote]hi,yeah this doesn't really help, as im adding data through a html file, the data gets added when there is one field, but if i add an extra field to that database then try adding data, then no data gets added, not even to the one that was working in the original place.any more help? Quote Link to comment Share on other sites More sharing options...
cnagra Posted April 17, 2006 Author Share Posted April 17, 2006 i got it workiing....YES!!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.