| | |
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 25 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; 25 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 25 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 24 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 |
advanced ajax api array basic beginner buttons c# c++ check checkbox class cms curl data database dehasher display dropdownlist eclipse ecommerce email fatalerror files flash form forms google html ibm image include insert integration java javascript jquery keyword keywords kickfire lamp limit link linux load login mail mariadb menu migrate multiple mysql mysqlquery network news number oop oracle paypal php post programming provider python query radio remote rss ruby script search security select server session smash sms soap spam sql subscription sun syntax table thread tutorial upload validation variable vb.net video view virus web webbrowser websitecontactform windows xml youtube zend







