multiple blank record entries?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    multiple blank record entries?

    Hey everyone,

    I keep getting multiple blank records entered along with my data everytime
    I submit my form.

    On the first page is the form itself without any code. On the 2nd page that
    it goes to after I hit submit is this:

    <?

    $select = "SELECT * FROM company,contact WHERE
    contact.company _id=company.com pany_id ORDER BY contact.company _id DESC
    LIMIT 10;";

    $result = mysql_query($se lect)or die("Invalid query: " . mysql_error());

    while ($row = mysql_fetch_ass oc($result)) {

    print '<b>'.$row['Subject'].'</b>'.'<br>';
    print $row['category'].'<br><br>';
    print $row['name'].' - ';
    print $row['email'].'<br><br>';
    print $row['location'].'<br><br>';
    }
    ?>


    Now everytime I hit submit on that page I get three other entries entered
    in at the same time. Also when I go to this page straight the data is
    displayed in an order I can't figure out.

    Any help is appreciated, thanks!
  • Jay Moore

    #2
    Re: multiple blank record entries?

    John wrote:[color=blue]
    > Hey everyone,
    >
    > I keep getting multiple blank records entered along with my data everytime
    > I submit my form.
    >
    > On the first page is the form itself without any code. On the 2nd page that
    > it goes to after I hit submit is this:
    >
    > <?
    >
    > $select = "SELECT * FROM company,contact WHERE
    > contact.company _id=company.com pany_id ORDER BY contact.company _id DESC
    > LIMIT 10;";
    >
    > $result = mysql_query($se lect)or die("Invalid query: " . mysql_error());
    >
    > while ($row = mysql_fetch_ass oc($result)) {
    >
    > print '<b>'.$row['Subject'].'</b>'.'<br>';
    > print $row['category'].'<br><br>';
    > print $row['name'].' - ';
    > print $row['email'].'<br><br>';
    > print $row['location'].'<br><br>';
    > }
    > ?>
    >
    >
    > Now everytime I hit submit on that page I get three other entries entered
    > in at the same time. Also when I go to this page straight the data is
    > displayed in an order I can't figure out.
    >
    > Any help is appreciated, thanks![/color]

    I might be missing something here, but I'm not seeing an INSERT or
    UPDATE command anywhere here.

    -Jay

    Comment

    • John

      #3
      Re: multiple blank record entries?

      Jay Moore <address@isp.tl d> wrote in
      news:NXl8c.35$z %1.11@twister.r dc-kc.rr.com:
      [color=blue]
      >
      > I might be missing something here, but I'm not seeing an INSERT or
      > UPDATE command anywhere here.[/color]

      oops, here is the insert info is:

      <?

      $query = "INSERT INTO optional (Subject,search _terms,location ) VALUES
      ('$Subject','$K eywords','$Desc ription')";
      mysql_query($qu ery) or die("Invalid query: " . mysql_error());

      $query = "INSERT INTO company
      (category,count ry,name,phone_n um,fax,address, city) VALUES
      ('$Industry','$ country','$Comp anyName','$Tel' ,'$Fax','$Maili ngAdd','$city')
      ";
      mysql_query($qu ery) or die("Invalid query: " . mysql_error());

      $query = "INSERT INTO contact (last_name,emai l) VALUES ('$Name','$Emai l')";
      mysql_query($qu ery) or die("Invalid query: " . mysql_error());
      ?>

      Comment

      • Jay Moore

        #4
        Re: multiple blank record entries?



        John wrote:[color=blue]
        > <snip stuff>[/color]

        Try commenting out your mysql_query() lines and echoing the $query to
        see if it changes.

        -Jay

        Comment

        • John

          #5
          Re: multiple blank record entries?

          Jay Moore <address@isp.tl d> wrote in news:3Bp8c.231$ z%1.175@twister .rdc-
          kc.rr.com:
          [color=blue]
          >
          >
          > John wrote:[color=green]
          >> <snip stuff>[/color]
          >
          > Try commenting out your mysql_query() lines and echoing the $query to
          > see if it changes.
          >
          > -Jay
          >[/color]


          Ok, that just stopped everything from entered, but I think you're on the
          right track.

          Here's the input again:

          <?

          $query = "INSERT INTO optional (Subject,search _terms,intro) VALUES
          ('$Subject','$K eywords','$Desc ription')";
          // mysql_query($qu ery) or die("Invalid query: " . mysql_error());

          $query = "INSERT INTO company
          (category,count ry,name,phone_n um,fax,address, city) VALUES
          ('$Industry','$ country','$Comp anyName','$Tel' ,'$Fax','$Maili ngAdd','$cit
          y')";
          // mysql_query($qu ery) or die("Invalid query: " . mysql_error());

          $query = "INSERT INTO contact (last_name,emai l) VALUES
          ('$Name','$Emai l')";
          // mysql_query($qu ery) or die("Invalid query: " . mysql_error());
          ?>

          How can I combine all those into one query instead of 3 seperate ones?
          If I do that I think it should fix it.

          Thanks again in advance :-)

          Comment

          • Jay Moore

            #6
            Re: multiple blank record entries?

            John wrote:[color=blue]
            > Ok, that just stopped everything from entered, but I think you're on the
            > right track.[/color]

            That was the point. I didn't want anything entered, just wanted to know
            what the query was each time it got to a '$query =' line.
            [color=blue]
            > How can I combine all those into one query instead of 3 seperate ones?
            > If I do that I think it should fix it.[/color]

            I'm no MySQL or PHP expert, but as far as I know, there is no way to
            INSERT into multiple databases with one statement. If I'm wrong, I'd
            appreciate someone telling me how to do it.

            -Jay

            Comment

            Working...