Jump to content

Archived

This topic is now archived and is closed to further replies.

cnagra

**SOLVED** PHP Newbie...Desperate Help!

Recommended Posts

hi,
please can someone help me, im new to php and have to create a stock control system
i 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

<?php

mysql_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

<?php

mysql_pconnect('localhost');
mysql_select_db('test2');

mysql_query("insert into test values ('$name')");
mysql_query("insert into test values ('$category')");

?>


please help...thanks

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
[!--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?

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.