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=firstbr Last Name: input type=text name=lastbr Phone: input type=text name=phonebr Mobile: input type=text name=mobilebr E-mail: input type=text name=emailbr Web: input type=text name=webbr input type=Submit value=click para enviar /form INSERT.PHP ? php echohello $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
Re: [PHP-DB] basic form entry
mysql_query (INSERT INTO users (First,Last,Phone,Mobile,Email,Web) VALUES ('$first_name','$last','$phone,'$mobile','$email','$web') ); echo('$username','$last') This doesn't work. You need to make a variable for the executed query, like, $query = mysql_query(.); After that, you get $query. But this is not the data you want. You can `echo` $query if you want to. What you get there is called resource id. So, you need to extract the data using mysql_fetch_something. Look up mysql_fetch_array or mysql_fetch_assoc for that infomation. You might wanna recheck mysql_query to know what you are really doing. On 10/7/07, sm [EMAIL PROTECTED] wrote: 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=firstbr Last Name: input type=text name=lastbr Phone: input type=text name=phonebr Mobile: input type=text name=mobilebr E-mail: input type=text name=emailbr Web: input type=text name=webbr input type=Submit value=click para enviar /form INSERT.PHP ? php echohello $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
Re: [PHP-DB] basic form entry
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 [EMAIL PROTECTED] To: sm [EMAIL PROTECTED] 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=firstbr Last Name: input type=text name=lastbr Phone: input type=text name=phonebr Mobile: input type=text name=mobilebr E-mail: input type=text name=emailbr Web: input type=text name=webbr input type=Submit value=click para enviar /form INSERT.PHP ? php echohello $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 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] basic form entry
echo('$username','$last') ??? what was your intention with this line? assuming your table's field names are as set in your query then everyuthing is OK. which brings me to the line above (which is quite oddly syntaxed!). Please explain what you meant by this and I may be able to help you further. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] pdo::mysql and unbuffered queries
I tried using pdo (www.php.net/pdo) as it would be nice for my projects to be portable to another database systems, but quickly ran into problems. The lesser important: One time, there was a simple typo in one of my queries and I got an error that php is not able to save session variables at the given path - I'm not joking! I worked several hours to solve that session problem just to realize the query had a bracket to few. I already got other errors in my queries where I was given a correct error trace, this is quite confusing. Can't comment on that one but if you can prove it in a small test script, post a bug report on http://bugs.php.net The bigger important: I was not able to build nested queries. Post your code. I doubt that the guys that developed PDO would stop something like this. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php