Jump to content

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


cnagra

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.