ok i decided to take Erwin Moller and start a fresh topic and im taking a different approach

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • so many sites so little time

    #1

    ok i decided to take Erwin Moller and start a fresh topic and im taking a different approach

    this time i am going to use the scripts from the book and just change
    the names to match what i am trying to do now i just got an error that
    i know shouldnt be an error i think. this is the error:

    Could add the site entry because: Column count doesn't match value
    count at row 1. The query was INSERT INTO home (home_id, header, body,
    date_entered) VALUES ('Welcome!', 'What is a Progressive Parent? A
    Progressive Parent ...

    now i created the table using what the book gave me which is:

    // Define the query.
    $query = 'CREATE TABLE home (
    home_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    header VARCHAR(100) NOT NULL,
    body TEXT NOT NULL,
    date_entered DATETIME NOT NULL
    )';

    // Run the query.
    if (@mysql_query ($query)) {
    print '<p>The table has been created.</p>';
    } else {
    die ('<p>Could not create the table because: <b>' . mysql_error() .
    '</b>.</p><p>The query being run was: ' . $query . '</p>');
    }

    and when i ran that script live i got the message "The table has been
    created."

    now when i run this script and try to insert the data is when i get the
    error message i posted above and that script looks like:

    // Define the query.
    $query = "INSERT INTO home (home_id, header, body, date_entered)
    VALUES ('{$_POST['header']}', '{$_POST['body']}', NOW())";

    // Execute the query.
    if (@mysql_query ($query)) {
    print '<p>The site entry has been added.</p>';
    } else {
    print "<p>Could add the site entry because: <b>" . mysql_error() .
    "</b>. The query was $query.</p>";
    }

    mysql_close();

    }

    // Display the form.
    ?>
    <form action="edit_si te.php" method="post">
    <p>Entry Title: <input type="text" name="header" size="40"
    maxsize="100" /></p>
    <p>Entry Text: <textarea name="body" cols="40" rows="5"></textarea></p>
    <input type="submit" name="submit" value="Add to the Site" />
    </form>

  • so many sites so little time

    #2
    Re: ok i decided to take Erwin Moller and start a fresh topic and im taking a different approach

    to me it looks like the dateentered and the home id arent being entered
    into the database correct?
    so many sites so little time wrote:
    this time i am going to use the scripts from the book and just change
    the names to match what i am trying to do now i just got an error that
    i know shouldnt be an error i think. this is the error:
    >
    Could add the site entry because: Column count doesn't match value
    count at row 1. The query was INSERT INTO home (home_id, header, body,
    date_entered) VALUES ('Welcome!', 'What is a Progressive Parent? A
    Progressive Parent ...
    >
    now i created the table using what the book gave me which is:
    >
    // Define the query.
    $query = 'CREATE TABLE home (
    home_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    header VARCHAR(100) NOT NULL,
    body TEXT NOT NULL,
    date_entered DATETIME NOT NULL
    )';
    >
    // Run the query.
    if (@mysql_query ($query)) {
    print '<p>The table has been created.</p>';
    } else {
    die ('<p>Could not create the table because: <b>' . mysql_error() .
    '</b>.</p><p>The query being run was: ' . $query . '</p>');
    }
    >
    and when i ran that script live i got the message "The table has been
    created."
    >
    now when i run this script and try to insert the data is when i get the
    error message i posted above and that script looks like:
    >
    // Define the query.
    $query = "INSERT INTO home (home_id, header, body, date_entered)
    VALUES ('{$_POST['header']}', '{$_POST['body']}', NOW())";
    >
    // Execute the query.
    if (@mysql_query ($query)) {
    print '<p>The site entry has been added.</p>';
    } else {
    print "<p>Could add the site entry because: <b>" . mysql_error() .
    "</b>. The query was $query.</p>";
    }
    >
    mysql_close();
    >
    }
    >
    // Display the form.
    ?>
    <form action="edit_si te.php" method="post">
    <p>Entry Title: <input type="text" name="header" size="40"
    maxsize="100" /></p>
    <p>Entry Text: <textarea name="body" cols="40" rows="5"></textarea></p>
    <input type="submit" name="submit" value="Add to the Site" />
    </form>

    Comment

    • so many sites so little time

      #3
      Re: ok i decided to take Erwin Moller and start a fresh topic and im taking a different approach

      this is the print out from phpmyadmin if you have used that before this
      might help you understand the structure of the table

      home:
      Field Type Null Default
      home_id int(10) No
      header varchar(100) No
      body text No
      date_entered datetime No 0000-00-00 00:00:00


      Indexes:
      Keyname Type Cardinality Field
      PRIMARY PRIMARY 0 home_id


      Space usage:
      Type Usage
      Data 0 B
      Index 1,024 B
      Total 1,024 B

      Row Statistics:
      Statements Value
      Format dynamic
      Rows 0
      Next Autoindex 1
      Creation Nov 19, 2006 at 10:43 AM
      Last update Nov 19, 2006 at 10:43 AM

      so many sites so little time wrote:
      to me it looks like the dateentered and the home id arent being entered
      into the database correct?
      so many sites so little time wrote:
      this time i am going to use the scripts from the book and just change
      the names to match what i am trying to do now i just got an error that
      i know shouldnt be an error i think. this is the error:

      Could add the site entry because: Column count doesn't match value
      count at row 1. The query was INSERT INTO home (home_id, header, body,
      date_entered) VALUES ('Welcome!', 'What is a Progressive Parent? A
      Progressive Parent ...

      now i created the table using what the book gave me which is:

      // Define the query.
      $query = 'CREATE TABLE home (
      home_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
      header VARCHAR(100) NOT NULL,
      body TEXT NOT NULL,
      date_entered DATETIME NOT NULL
      )';

      // Run the query.
      if (@mysql_query ($query)) {
      print '<p>The table has been created.</p>';
      } else {
      die ('<p>Could not create the table because: <b>' . mysql_error() .
      '</b>.</p><p>The query being run was: ' . $query . '</p>');
      }

      and when i ran that script live i got the message "The table has been
      created."

      now when i run this script and try to insert the data is when i get the
      error message i posted above and that script looks like:

      // Define the query.
      $query = "INSERT INTO home (home_id, header, body, date_entered)
      VALUES ('{$_POST['header']}', '{$_POST['body']}', NOW())";

      // Execute the query.
      if (@mysql_query ($query)) {
      print '<p>The site entry has been added.</p>';
      } else {
      print "<p>Could add the site entry because: <b>" . mysql_error() .
      "</b>. The query was $query.</p>";
      }

      mysql_close();

      }

      // Display the form.
      ?>
      <form action="edit_si te.php" method="post">
      <p>Entry Title: <input type="text" name="header" size="40"
      maxsize="100" /></p>
      <p>Entry Text: <textarea name="body" cols="40" rows="5"></textarea></p>
      <input type="submit" name="submit" value="Add to the Site" />
      </form>

      Comment

      • Norman Peelman

        #4
        Re: ok i decided to take Erwin Moller and start a fresh topic and im taking a different approach

        "so many sites so little time" <kkddrpg@gmail. comwrote in message
        news:1163951865 .217385.224180@ m73g2000cwd.goo glegroups.com.. .
        this time i am going to use the scripts from the book and just change
        the names to match what i am trying to do now i just got an error that
        i know shouldnt be an error i think. this is the error:
        >
        Could add the site entry because: Column count doesn't match value
        count at row 1. The query was INSERT INTO home (home_id, header, body,
        date_entered) VALUES ('Welcome!', 'What is a Progressive Parent? A
        Progressive Parent ...
        >
        now i created the table using what the book gave me which is:
        >
        // Define the query.
        $query = 'CREATE TABLE home (
        home_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
        header VARCHAR(100) NOT NULL,
        body TEXT NOT NULL,
        date_entered DATETIME NOT NULL
        )';
        >
        // Run the query.
        if (@mysql_query ($query)) {
        print '<p>The table has been created.</p>';
        } else {
        die ('<p>Could not create the table because: <b>' . mysql_error() .
        '</b>.</p><p>The query being run was: ' . $query . '</p>');
        }
        >
        and when i ran that script live i got the message "The table has been
        created."
        >
        now when i run this script and try to insert the data is when i get the
        error message i posted above and that script looks like:
        >
        // Define the query.
        $query = "INSERT INTO home (home_id, header, body, date_entered)
        VALUES ('{$_POST['header']}', '{$_POST['body']}', NOW())";
        >
        // Execute the query.
        if (@mysql_query ($query)) {
        print '<p>The site entry has been added.</p>';
        } else {
        print "<p>Could add the site entry because: <b>" . mysql_error() .
        "</b>. The query was $query.</p>";
        }
        >
        mysql_close();
        >
        }
        >
        First problem is you are not entering your home_id at all (it takes a 0 -
        zero or a NULL to work), make your $query look like this:

        $query = "INSERT INTO home (home_id, header, body, date_entered) VALUES
        (NULL,'{$_POST['header']}', '{$_POST['body']}', NOW())";

        ....and second (and personal taste) is if you aren't using multi-dimensional
        arrays you can do it this way:

        $query = "INSERT INTO home (home_id, header, body, date_entered) VALUES
        (NULL,'$_POST[header]', '$_POST[body]', NOW())";




        // Display the form.
        ?>
        <form action="edit_si te.php" method="post">
        <p>Entry Title: <input type="text" name="header" size="40"
        maxsize="100" /></p>
        <p>Entry Text: <textarea name="body" cols="40" rows="5"></textarea></p>
        <input type="submit" name="submit" value="Add to the Site" />
        </form>
        >


        Norm
        --
        FREE Avatar hosting at www.easyavatar.com


        Comment

        • Jerry Stuckle

          #5
          Re: ok i decided to take Erwin Moller and start a fresh topic andim taking a different approach

          Norman Peelman wrote:
          "so many sites so little time" <kkddrpg@gmail. comwrote in message
          news:1163951865 .217385.224180@ m73g2000cwd.goo glegroups.com.. .
          >
          >>this time i am going to use the scripts from the book and just change
          >>the names to match what i am trying to do now i just got an error that
          >>i know shouldnt be an error i think. this is the error:
          >>
          >>Could add the site entry because: Column count doesn't match value
          >>count at row 1. The query was INSERT INTO home (home_id, header, body,
          >>date_entere d) VALUES ('Welcome!', 'What is a Progressive Parent? A
          >>Progressive Parent ...
          >>
          >>now i created the table using what the book gave me which is:
          >>
          >>// Define the query.
          >>$query = 'CREATE TABLE home (
          >>home_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
          >>header VARCHAR(100) NOT NULL,
          >>body TEXT NOT NULL,
          >>date_entere d DATETIME NOT NULL
          >>)';
          >>
          >>// Run the query.
          >>if (@mysql_query ($query)) {
          >>print '<p>The table has been created.</p>';
          >>} else {
          >>die ('<p>Could not create the table because: <b>' . mysql_error() .
          >>'</b>.</p><p>The query being run was: ' . $query . '</p>');
          >>}
          >>
          >>and when i ran that script live i got the message "The table has been
          >>created."
          >>
          >>now when i run this script and try to insert the data is when i get the
          >>error message i posted above and that script looks like:
          >>
          >>// Define the query.
          >>$query = "INSERT INTO home (home_id, header, body, date_entered)
          >>VALUES ('{$_POST['header']}', '{$_POST['body']}', NOW())";
          >>
          >>// Execute the query.
          >>if (@mysql_query ($query)) {
          >>print '<p>The site entry has been added.</p>';
          >>} else {
          >>print "<p>Could add the site entry because: <b>" . mysql_error() .
          >>"</b>. The query was $query.</p>";
          >>}
          >>
          >>mysql_close() ;
          >>
          >>}
          >>
          >
          >
          First problem is you are not entering your home_id at all (it takes a 0 -
          zero or a NULL to work), make your $query look like this:
          >
          Incorrect. It is perfectly valid to not enter home_id in the INSERT
          statement. The autonum value will be used.
          $query = "INSERT INTO home (home_id, header, body, date_entered) VALUES
          (NULL,'{$_POST['header']}', '{$_POST['body']}', NOW())";
          >
          This will also work, but is not necessary.
          ...and second (and personal taste) is if you aren't using multi-dimensional
          arrays you can do it this way:
          >
          $query = "INSERT INTO home (home_id, header, body, date_entered) VALUES
          (NULL,'$_POST[header]', '$_POST[body]', NOW())";
          >
          >
          Additionally, you should never use data entered by the user without
          validating it. Additionally, any data entered should be processed by
          mysql_real_esca pe_string() before placing in the database.
          >
          >
          >
          >
          >>// Display the form.
          >>?>
          >><form action="edit_si te.php" method="post">
          >><p>Entry Title: <input type="text" name="header" size="40"
          >>maxsize="10 0" /></p>
          >><p>Entry Text: <textarea name="body" cols="40" rows="5"></textarea></p>
          >><input type="submit" name="submit" value="Add to the Site" />
          >></form>
          >>
          >
          >
          >
          Norm

          --
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstucklex@attgl obal.net
          =============== ===

          Comment

          • Pedro Graca

            #6
            Re: ok i decided to take Erwin Moller and start a fresh topic and im taking a different approach

            Jerry Stuckle wrote:
            Norman Peelman wrote:
            >"so many sites so little time" <kkddrpg@gmail. comwrote in message
            >news:116395186 5.217385.224180 @m73g2000cwd.go oglegroups.com. ..
            >>>// Define the query.
            >>>$query = "INSERT INTO home (home_id, header, body, date_entered)
            ^==1==^ ^==2=^ ^=3^ ^=====4====^
            >>>VALUES ('{$_POST['header']}', '{$_POST['body']}', NOW())";
            ^=========1==== ====^ ^========2===== ==^ ^=3=^

            ERROR 1136 (21S01): Column count doesn't match value count ...

            4 columns (home_id, header, body, and date_entered) and 3 values give
            the error 1136 in my MySQL (v 4.1.10)
            >First problem is you are not entering your home_id at all (it takes a 0 -
            >zero or a NULL to work), make your $query look like this:
            >
            Incorrect. It is perfectly valid to not enter home_id in the INSERT
            statement. The autonum value will be used.
            I agree with Norm :)
            The SQL statement from "so many sites so little time" generates an
            error.

            The only way to make it valid is to eliminate it from the column
            specification:

            $query = "INSERT INTO home (header, body, date_entered)
            VALUES ('{$_POST['header']}', '{$_POST['body']}', NOW())";



            --
            I (almost) never check the dodgeit address.
            If you *really* need to mail me, use the address in the Reply-To
            header with a message in *plain* *text* *without* *attachments*.

            Comment

            • so many sites so little time

              #7
              Re: ok i decided to take Erwin Moller and start a fresh topic and im taking a different approach

              thanks so much for all the help im going to remove the home_id if that
              doesnt work i am going to make it null all i am really trying to achive
              in the end is a page where a client could enter that they would like
              text on their site to be and update the database with that text and a
              script that would display that text. i went out tonight and bought
              another php book its the php phrasebook by chris wenz. i have quite a
              few books on php and or mysql 4 to be exact and none of them really got
              what i needed for this through to my head but tonight a sat at borders
              with a cup of coffee and read through the section on inserting and
              displaying data from a mysql database from the sections of every single
              php, and php and mysql book that they had in stock and took notes so i
              should be golden if there are anymore problems or errors with this i
              will let you guys know so you can be of help and that you all for
              helping so much you are all really good people for taking the time to
              help me out. : )
              Pedro Graca wrote:
              Jerry Stuckle wrote:
              Norman Peelman wrote:
              "so many sites so little time" <kkddrpg@gmail. comwrote in message
              news:1163951865 .217385.224180@ m73g2000cwd.goo glegroups.com.. .
              >>// Define the query.
              >>$query = "INSERT INTO home (home_id, header, body, date_entered)
              ^==1==^ ^==2=^ ^=3^ ^=====4====^
              >>VALUES ('{$_POST['header']}', '{$_POST['body']}', NOW())";
              ^=========1==== ====^ ^========2===== ==^ ^=3=^
              >
              ERROR 1136 (21S01): Column count doesn't match value count ...
              >
              4 columns (home_id, header, body, and date_entered) and 3 values give
              the error 1136 in my MySQL (v 4.1.10)
              >
              First problem is you are not entering your home_id at all (it takes a 0 -
              zero or a NULL to work), make your $query look like this:
              Incorrect. It is perfectly valid to not enter home_id in the INSERT
              statement. The autonum value will be used.
              >
              I agree with Norm :)
              The SQL statement from "so many sites so little time" generates an
              error.
              >
              The only way to make it valid is to eliminate it from the column
              specification:
              >
              $query = "INSERT INTO home (header, body, date_entered)
              VALUES ('{$_POST['header']}', '{$_POST['body']}', NOW())";
              >
              >
              >
              --
              I (almost) never check the dodgeit address.
              If you *really* need to mail me, use the address in the Reply-To
              header with a message in *plain* *text* *without* *attachments*.

              Comment

              • Jerry Stuckle

                #8
                Re: ok i decided to take Erwin Moller and start a fresh topic andim taking a different approach

                so many sites so little time wrote:
                thanks so much for all the help im going to remove the home_id if that
                doesnt work i am going to make it null all i am really trying to achive
                in the end is a page where a client could enter that they would like
                text on their site to be and update the database with that text and a
                script that would display that text. i went out tonight and bought
                another php book its the php phrasebook by chris wenz. i have quite a
                few books on php and or mysql 4 to be exact and none of them really got
                what i needed for this through to my head but tonight a sat at borders
                with a cup of coffee and read through the section on inserting and
                displaying data from a mysql database from the sections of every single
                php, and php and mysql book that they had in stock and took notes so i
                should be golden if there are anymore problems or errors with this i
                will let you guys know so you can be of help and that you all for
                helping so much you are all really good people for taking the time to
                help me out. : )
                Pedro Graca wrote:
                >
                >>Jerry Stuckle wrote:
                >>
                >>>Norman Peelman wrote:
                >>>
                >>>>"so many sites so little time" <kkddrpg@gmail. comwrote in message
                >>>>news:116395 1865.217385.224 180@m73g2000cwd .googlegroups.c om...
                >>>>
                >>>>>// Define the query.
                >>>>>$query = "INSERT INTO home (home_id, header, body, date_entered)
                >>
                > ^==1==^ ^==2=^ ^=3^ ^=====4====^
                >>
                >>>>>VALUES ('{$_POST['header']}', '{$_POST['body']}', NOW())";
                >>
                > ^=========1==== ====^ ^========2===== ==^ ^=3=^
                >>
                >>ERROR 1136 (21S01): Column count doesn't match value count ...
                >>
                >>4 columns (home_id, header, body, and date_entered) and 3 values give
                >>the error 1136 in my MySQL (v 4.1.10)
                >>
                >>
                >>>>First problem is you are not entering your home_id at all (it takes a 0 -
                >>>>zero or a NULL to work), make your $query look like this:
                >>>
                >>>Incorrect. It is perfectly valid to not enter home_id in the INSERT
                >>>statement. The autonum value will be used.
                >>
                >>I agree with Norm :)
                >>The SQL statement from "so many sites so little time" generates an
                >>error.
                >>
                >>The only way to make it valid is to eliminate it from the column
                >>specification :
                >>
                >>$query = "INSERT INTO home (header, body, date_entered)
                >>VALUES ('{$_POST['header']}', '{$_POST['body']}', NOW())";
                >>
                >>
                >>
                >>--
                >>I (almost) never check the dodgeit address.
                >>If you *really* need to mail me, use the address in the Reply-To
                >>header with a message in *plain* *text* *without* *attachments*.
                >
                >
                While you're at it, please buy a book on how to post to usenet. You're
                making things much harder on yourself in the way you're posting.

                If you were posting properly you would get a lot more responses to your
                messages.

                --
                =============== ===
                Remove the "x" from my email address
                Jerry Stuckle
                JDS Computer Training Corp.
                jstucklex@attgl obal.net
                =============== ===

                Comment

                • Erwin Moller

                  #9
                  Re: ok i decided to take Erwin Moller and start a fresh topic and im taking a different approach

                  so many sites so little time wrote:

                  <snip>

                  You took ME?
                  Woot, I completely missed that. :P

                  Erwin Moller

                  Comment

                  Working...