Re: Posting to a database
| From: | Jason Sheets | Date: | Sun, 04 May 2003 16:13:39 +0000 |
| Subject: | Re: Posting to a database | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-146369@lists.php.net to get a copy of this message | ||
It looks like you have an extra comma in SQL query, take a look at
VALUES ('$company','$start','$description', '$rep',) you have a comment after '$rep' indicating you intend to provide another value, try taking that out.
In general when your SQL does not work as expected try echo $sql and look at the SQL to see if it is what you expect and also use mysql_error to determine what the error on the db is.
Jason
Brent Lee wrote:
Hi all, I'm new to all this. could someone tell me why this script doesn't post to my Database? <HTML> <?php if($submit) { $db = mysql_connect("localhost", "XXXXXX","xxxxxxxx"); mysql_select_db("xxxxxxxx",$db); $sql = "INSERT INTO current (Company, Start, Description, DWSRep) VALUES ('$company','$start','$description', '$rep',)"; $result = mysql_query($sql); echo "PIP Information Updated."; } else { ?> <form method="post" action="data_input.php"> Customer name:<input type="Text" name="company"><br> Start Date: <input type="Text" name="start"><br> Project Description: <input type="Text" name="description"><br> DWS Representative: <input type="Text" name="rep"><br> <input type="Submit" name="submit" value="Update PIP"></form> <? } ?> </HTML> I get the "PIP Information updated" message back but when i view the Database there is no new information in it. I'm reading as fast as I can but having someone to ask questions is very helpfull. -- Thanks all.