Re: Adding Record to database

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

 



Matt,

Check a couple of things:

1. Do you have a primary key with unique id? You could be getting a key violation.
2. Echo $query and confirm that it is as you expect.
3. Add code to trap for, or at least display any generated error.
4. Are you able to test this INSERT at the MySQL console?

If so, and it works, compare what works in 4. with what you have at 2.

HTH -Miles


At 08:41 PM 2/2/2003 -0500, Matt wrote:
Hi.  I am having a problem with adding a record into a table of a database.
I have attached the code I am using to accomplish this.  It works if the
table is empty, but if there is already a record in the table, it won't add
anything.  Could anyone help me out with this?  Here is the code I am using:

$query = "INSERT INTO TableName
(SID,StudentLastName,StudentFirstName,StudentEmail,StudentLoginName,StudentP
assword) VALUES
('$SID','$StudentLastName','$StudentFirstName','$StudentEmail','$StudentLogi
nName','$StudentLoginPassword')";
$results = mysql_query($query);

Like I said, this works if the table is totally empty, but if there is
already an entry in there, it does nothing.  Please help if you can.
Thanks.

Matt



--
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