|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
|
|
#1
|
|||
|
|||
|
inserting into database
I have this php news system with MYSQL and I am finding the simple task annoyingly hard. I have a form where you fill in detail and pess submit and the details go into the database. I have done this before using two seperate pages one with the form in it and the other with the action but now i am wanting to expand my knowledge and wanting the action on the same page so far I have made this
---------------------------------------- <? if($HTTP_POST_VARS['submit']) { $by=$HTTP_POST_VARS['by']; $snews=$HTTP_POST_VARS['snews']; $fnews=$HTTP_POST_VARS['fnews']; $pass=$HTTP_POST_VARS['pass']; include("dbinfo.inc.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="INSERT INTO webnews ( by, snews, fnews) VALUES( '".$by."', '".$snews."', '".$fnews."')"; mysql_query($query); echo "Record Updated"; mysql_close(); } ?> <strong>Insert news </strong> <form name="insert" method="post" action="<?=$PHP_SELF?>"> <p>By</p> <p> <input name="by" type="text" > </p> <p>Short News </p> <p> <textarea name="snews" cols="50" rows="2" wrap="VIRTUAL"></textarea> </p> <p>Full news</p> <p> <textarea name="fnews" cols="50" rows="10"></textarea> </p> <p>Password </p> <p> <input name="pass" type="password" value=""> </p> <p> <input type="submit" name="Submit" value="Insert"> </p> </form> -------------------------------------- Thank you |
|
#2
|
||||
|
||||
|
And the problem is...
|
|
#3
|
|||
|
|||
|
It wont put any of the data into the databse when I press submit
|
|
#4
|
||||
|
||||
|
try outputting the SQL statement... i've found that generally leads me to the solution when i have a problem...
it may help to output the variables as well, to make sure they're getting passed properly... |
|
#5
|
|||
|
|||
|
well I have updated it and I can now get the values to be outputed but not get into the databse and if anyone can see what is wrong please tell me
PHP Code:
|
|
#6
|
|||
|
|||
|
Did you ever figure this out? By looking at your provided code, you have "by" as the text box for the Author but you have "auther" in your code. So change "by" to "auther" in your form and it should work.
Chris |
|
#7
|
|||
|
|||
|
yes i did get this working thanks for all the help guys
|
|
#8
|
|||
|
|||
|
Enter data to the database through tabular page
I want to make a table containing some fields like date
,customer_name etc. using this table i want to enter the data to the database But i wont know how to edit the table through html/php page. Please help |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Database Development > inserting into database |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|