Jump to content


Photo

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


  • Please log in to reply
3 replies to this topic

#1 cnagra

cnagra
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 17 April 2006 - 02:07 AM

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

#2 litebearer

litebearer
  • Members
  • PipPipPip
  • Advanced Member
  • 2,357 posts
  • Locationwhite lake michigan

Posted 17 April 2006 - 02:13 AM

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...

all the brothers were valiant!

[br][br]The truely intelligent people are not those who create the dots; rather they are they ones with the ability to connect the dots into a coherent picture

#3 cnagra

cnagra
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 17 April 2006 - 02:18 AM

[!--quoteo(post=365426:date=Apr 16 2006, 09:13 PM:name=litebearer)--][div class=\'quotetop\']QUOTE(litebearer @ Apr 16 2006, 09:13 PM) View Post[/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?

#4 cnagra

cnagra
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 17 April 2006 - 03:02 AM

i got it workiing....YES!!!!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users