The forums have permanently moved to This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

Results 1 to 5 of 5

Thread: mysql_query isnt working

  1. #1

    mysql_query isnt working

    I have a form that is suposed to insert a new record in to the db when someone clicks on the submit button

    I think i have it set u p correctly her is my page

    PHP Code:
    if (isset ($_POST['post'])){
    $tanounce $_POST['announcements'];
    $announce trim($tannounce);
                    if ( !empty(
    $announce) ) 
    mysql_query("INSERT INTO `impactathletics`.`team` (`announcements`)
    WHERE team_id = '1' 
    VALUES ('
                <form method="post" action="<?php echo $_SERVER['PHP_SELF'?>">
                    <textarea name="announcements" cols="45" rows="5"></textarea>
                    <br />
                    <input type="submit" value="Submit" />
                    <br />
    can any one see the problem?
    side note the table its supposed to be inserted into already contains info. Will it add to the field? or will it drop it.

  2. #2
    not much help with there php, but there is a spelling mistake on the closing tag for html.

    </html> you put </heml>
    My Photography

    K-Emmys-06: Best "Newbie"

  3. #3
    INSERT will ONLY add NEW entries not UPDATE them

    if you needed to insert something the format is
    mysql_query("INSERT INTO table (col1, col2) VALUES('val1', 'val2' ) ")
    notice there is no WHERE statement in an insert... so what you're looking for is UPDATE
    mysql_query("UPDATE table SET col = 'val' WHERE col = 'currentval' ")
    Let us live so that when we come to die even the undertaker will be sorry. - Mark Twain
    Don't PM me your CSS, xHTML, JS or PHP questions. I will not reply to ANY IE6 questions.

  4. #4
    oooooo. I see now. Thanks again. It was weird i ran the script and i didnt receive any errors but it also didn't post to the db when i executed. Ill give it a go. thanks again guys.

  5. #5
    im an idiot... i did the update query and it still didn't work.. but i figured out my problem... i forgot to give a name to the submit button ><

    at least i found it

    thanks again every1

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Home About Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012