Lynne,

1. Where are you testing for the action of the form?
2. What triggers the insert?

For more on this, have a look at the custom error tutorial put up by Julie 
Meloni at http://www.thickbook.com

Right now it looks as if you are inserting a record every time the page 
loads. So you would get a record on the initial load, when $event_title and 
$event_desc are empty, on the submit, when they have values, and on the 
following reload, if you do one.

Hope this helps - Miles Thompson

At 07:28 AM 12/9/2001 -0500, Lynne wrote:
>Using simple test scripts, I'm connecting to a MySQL DB through PHP after
>inputting info into a form and hitting submit. Something is putting three
>records instead of one into the mySQL DB.
>
>For instance:
>the two variables are: $event_title and $event_desc. These are gotten from
>the form submitting to the PHP doc. The PHP code is as follows:
>
><?php
>
>$link = mysql_connect("localhost", "llupien", "dod2196");
>if (! $link)
>  die ("Couldn't connect to MySQL");
>mysql_select_db("scco") or die ("Couldn't open database phptest");
>$query = "INSERT INTO events (title,description) values
>('$event_title','$event_desc')";
>mysql_query($query, $link) or die ("Couldn't add data to table:
>".mysql_error());
>mysql_close($link);
>
>?>
>
>
>It's simple and I know the syntax is right...but in my simple little table,
>I get three records - one correctly entered and two blanks. The two blanks
>force the autonumber ID field to increment, but are completely blank
>otherwise. Why would I get three records?
>
>I use MySQL and PHP with my hosting service...they have PHPMyAdmin
>installed...when you add a record from PHPMyAdmin, it works peachy. So
>something PHP is working just fine, just not *my* scripts.
>
>One of my theories is that it's something about the way I
>connect..."localhost" may be wrong or need a port?? I've asked them over and
>over what the connection requires but they don't seem to know what they're
>talkign about. They keep telling me the pathway "usr/local/mysql" etc, but
>can't tell me how to connect to the mySQL db's.
>
>Anyway, it might be hopeless, but I'm hoping someone can lead me in the
>right direction. Thanks!
>Lynne
>
>
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to