Re: basic form entry

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
To: "sm" <shojiki1@xxxxxxxxxxx>
Cc: <php-db@xxxxxxxxxxxxx>
Sent: Sunday, October 07, 2007 4:47 AM
Subject: Re:  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

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux