Re: basic form entry

From: Date: Sun, 07 Oct 2007 13:14:11 +0000
Subject: Re: basic form entry
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-44171@lists.php.net to get a copy of this message
If you are still having issues with this, try echoing out your query to the browser before sending the query to the database. Once you do that, you can look at the query that will be sent to the database. If there is an error there, you can fix it. If not, you can rule out your query string as the source of the problem and begin checking things like the database, its connection, the privileges you set for the db login used to perform the insert, etc. But troubleshoot your query string as I described first. ----- Original Message ----- From: "Olavi Ivask" <olavi@city.ee> To: "sm" <shojiki1@hotmail.com> Cc: <php-db@lists.php.net> Sent: Sunday, October 07, 2007 4:47 AM Subject: Re: [PHP-DB] basic form entry
INSERT inserts new data to database. If you want to update data, use UPDATE instead of INSERT. Olavi Ivask I have been racking my brains trying to figure out what I am doing wrong.
i have created a basic form that calls requests user information...the form then runs insert.php. No errors are returned, however, my database does not update. Any suggestions? thanks The field names in the table are correct (case). SUBMIT.HTML: <form action="insert.php" method="post"> First Name: <input type="text" name="first"><br> Last Name: <input type="text" name="last"><br> Phone: <input type="text" name="phone"><br> Mobile: <input type="text" name="mobile"><br> E-mail: <input type="text" name="email"><br> Web: <input type="text" name="web"><br> <input type="Submit" value="click para enviar"> </form> INSERT.PHP <? php echo"hello" $username = "guest"; $psswd = "password"; $db = "contacts"; $host = "localhost"; $first_name = $_POST['first']; $last = $_POST['last']; $phone = $_POST['phone']; $mobile = $_POST['mobile']; $email = $_POST['email']; $web = $_POST['web']; mysql_connect($host,$username,$psswd) or die ("errror in access db"); mysql_select_db($db); mysql_query ("INSERT INTO users (First,Last,Phone,Mobile,Email,Web) VALUES ('$first_name','$last','$phone,'$mobile','$email','$web') "); echo('$username','$last') echo mysql_error(mysql_connect($host,$username,$psswd)); ?> -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.db (#44171) next »