basic form entry
am 07.10.2007 05:20:13 von SM
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:
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
Re: basic form entry
am 07.10.2007 10:47:03 von olavi
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:
>
>
>
>
> 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
Re: basic form entry
am 07.10.2007 15:11:57 von T K
> 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 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:
>
>
>
>
> 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
Re: basic form entry
am 07.10.2007 15:14:11 von Rich Hutchins
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"
To: "sm"
Cc:
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:
>>
>>
>>
>>
>> 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
Re: basic form entry
am 07.10.2007 21:59:00 von Ben
> 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: basic form entry
am 08.10.2007 10:58:02 von Oskar
most likely you have a problem in your query but you dont understand how
to use mysql_error.
from http://www.php.net/manual/en/function.mysql-error.php :
string *mysql_error* ( [resource $link_identifier] )
Returns the error text from the last MySQL function
> echo mysql_error(mysql_connect($host,$username,$psswd));
>
you see now? you are creating new connection. correct code should appear
similar to this:
$connection=mysql_connect($host,$username,$psswd) or die ("errror in access db");
mysql_select_db($db,$connection);
if (!mysql_query ("INSERT INTO users (First,Last,Phone,Mobile,Email,Web) VALUES
('$first_name','$last','$phone,'$mobile','$email','$web') ",$connection)) echo("error ".mysql_error($connection));
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php