| | |
Newbie question: PHP form not writing to MySQL database
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
0
#12 18 Days Ago
aahhh its fine... i was starting to get worried that after spending 2 months coding, some1 s suggesting me to read that absolute beginners stuff.. 

Last edited by venkat0904; 18 Days Ago at 6:30 am.
Gimme reputation points if u find my post helpful.
use [code] tags wherever applicable
dont start a new thread unless u cant find the topic already on forum.
mark a thread "solved" as soon as u get a solution
use [code] tags wherever applicable
dont start a new thread unless u cant find the topic already on forum.
mark a thread "solved" as soon as u get a solution
•
•
Join Date: Aug 2008
Posts: 4
Reputation:
Solved Threads: 0
0
#13 18 Days Ago
Still not working for me. I don't know the code, so I'm not sure what to look for, but I made sure that all the variable names and everything were correct.
Here's the code that I'm using:
If this helps, when I use PuTTY to check the contents of the database, I see this:
Thanks! I'll look at that now.
Here's the code that I'm using:
PHP Syntax (Toggle Plain Text)
<FORM ACTION="<?php echo($PHP_SELF); ?>" METHOD="post"> <P>Type your word here:<BR> <TEXTAREA NAME="word" ROWS="2" COLS="40" WRAP="HARD"></TEXTAREA><BR> <INPUT TYPE="SUBMIT" NAME="submitWord" VALUE="SUBMIT"> </FORM> <?php $word = $_POST['submitWord']; if ("SUBMIT" == $submitWord) { $sql = "INSERT INTO Dictionary SET " . "Word='$word', " . "AddDate=CURDATE()"; if (mysql_query($sql)) { echo("<P>Your word has been added.</P>"); } else { echo("<P>Error adding submitted word: " . mysql_error() . "</P>"); } } ?>
If this helps, when I use PuTTY to check the contents of the database, I see this:
PHP Syntax (Toggle Plain Text)
mysql> select * from Dictionary; +----+----------+------+----------------------------------------------+------------+ | ID | Word | PoS | Definition | AddDate | +----+----------+------+----------------------------------------------+------------+ | 2 | abstract | adj | NULL | 0000-00-00 | | 3 | abstract | adj | NULL | 0000-00-00 | | 4 | abstract | adj | not concrete; hard to understand; intangible | 2009-11-08 | +----+----------+------+----------------------------------------------+------------+ 3 rows in set (0.01 sec)
Thanks! I'll look at that now.
0
#14 17 Days Ago
why dont u use the code suggested above... ur sql query syntax itself is wrong.. how do you expect to get a database entry with that...
general syntax for insert statement is-
INSERT INTO [tablename] (col1,col2 ...) VALUES (val1, val2...);
Also ur table structure shows other fields also besides word and date... are u sure when u are inserting a new row, these values are allowed to be null?
general syntax for insert statement is-
INSERT INTO [tablename] (col1,col2 ...) VALUES (val1, val2...);
Also ur table structure shows other fields also besides word and date... are u sure when u are inserting a new row, these values are allowed to be null?
•
•
•
•
Still not working for me. I don't know the code, so I'm not sure what to look for, but I made sure that all the variable names and everything were correct.
Here's the code that I'm using:
PHP Syntax (Toggle Plain Text)
<FORM ACTION="<?php echo($PHP_SELF); ?>" METHOD="post"> <P>Type your word here:<BR> <TEXTAREA NAME="word" ROWS="2" COLS="40" WRAP="HARD"></TEXTAREA><BR> <INPUT TYPE="SUBMIT" NAME="submitWord" VALUE="SUBMIT"> </FORM> <?php $word = $_POST['submitWord']; if ("SUBMIT" == $submitWord) { $sql = "INSERT INTO Dictionary SET " . "Word='$word', " . "AddDate=CURDATE()"; if (mysql_query($sql)) { echo("<P>Your word has been added.</P>"); } else { echo("<P>Error adding submitted word: " . mysql_error() . "</P>"); } } ?>
If this helps, when I use PuTTY to check the contents of the database, I see this:PHP Syntax (Toggle Plain Text)
mysql> select * from Dictionary; +----+----------+------+----------------------------------------------+------------+ | ID | Word | PoS | Definition | AddDate | +----+----------+------+----------------------------------------------+------------+ | 2 | abstract | adj | NULL | 0000-00-00 | | 3 | abstract | adj | NULL | 0000-00-00 | | 4 | abstract | adj | not concrete; hard to understand; intangible | 2009-11-08 | +----+----------+------+----------------------------------------------+------------+ 3 rows in set (0.01 sec)
Thanks! I'll look at that now.
Gimme reputation points if u find my post helpful.
use [code] tags wherever applicable
dont start a new thread unless u cant find the topic already on forum.
mark a thread "solved" as soon as u get a solution
use [code] tags wherever applicable
dont start a new thread unless u cant find the topic already on forum.
mark a thread "solved" as soon as u get a solution
![]() |
Similar Threads
- Inserting data to mysql database using php created form (MySQL)
- Help with php script to export mysql data and import data (PHP)
- How do I pass values with a link into mySQL database using PHP? (PHP)
- Creating User Manual in Vb6 and Populating TreeView from Mysql database VB6 (Visual Basic 4 / 5 / 6)
- Help! my script couldn't submit form data to mysql database (PHP)
- Parsing html form. (PHP)
- PHP MySQL Database Help (MySQL)
- Big question: lINE BREAKS IN PHP TEXT POSTED TO MYSQL DATABASE (PHP)
- PHP form problem. (PHP)
- Online voting (PHP)
Other Threads in the PHP Forum
- Previous Thread: Multiple Text areas not working.
- Next Thread: problem with image submit button
| Thread Tools | Search this Thread |
ajax amf api applicaions array asp basic beginner body broken c# c++ calculator check checkbox class cms combobox cookies curl database date display dojofoundation duplicates email errorlog execute files flash folder form forms forum gentoo google gui html ibm image include ingres insert java javascript job jquery keywords lamp limit link linux login mail malfunction memmory memory menu montywidenius multiple mysql mysqlquery navigation news nodes number oop open opendatabasealliance oracle php post programming protocol python query radio recourse remote script search security select server sms spam sql sqlserver sun syntax table tutorial upload video web windows wpf yahoo youtube zend







