Query not successful with PHP into MySQL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jaime Andres Aranguren Cardona

    Query not successful with PHP into MySQL

    Hi,

    I created mysql table with one index column, with AUTO_INCREMENT
    feature. (and the other columns too: Nombre, Apellidos, email,
    Direccion, Ciudad, Pais)

    In my code, I have:

    // Take dat from HTML form
    $Nombre = $_POST["Nombre"];
    $Apellidos = $_POST["Apellidos"];
    $email = $_POST["e-mail"];
    $Direccion = $_POST["Direccion"];
    $Ciudad = $_POST["Ciudad"];
    $Pais = $_POST["Pais"];
    $Categoria = $_POST["ProductServOpc ion"];

    // MySQL server connection
    $link = mysql_connect ("servidor", "usuario",
    "password") or die ("No pudo conectarse a servidor
    MySQL.");

    // Database selection
    mysql_select_db ("baseDatos" ) or die("No pudo
    seleccionarse la base de datos.");

    // Query to insert data into table
    $insertionQuery = "INSERT INTO Usuarios (Nombre,
    Apellidos, email, Direccion, Ciudad, Pais) VALUES
    ('$Nombre','$Ap ellidos','$emai l','$Direccion' ,'$Ciudad','$Pa is')";

    // Query execution
    $insertionResul t = mysql_query($in sertionQuery) or
    die("La consulta de inserció n fall&oacute");

    The message I get is precisely: "La consulta de inserción falló"
    (Insertion query failed, in english). And the php script dies.

    The strange part is that the first time I ran the html form and php
    script, everything was OK. But no more than the first time.

    What can be wrong?

    All of your help is needed.

    Regards,

    JaaC
  • Pedro Graca

    #2
    Re: Query not successful with PHP into MySQL

    Jaime Andres Aranguren Cardona wrote:
    (snip)[color=blue]
    > // Query execution
    > $insertionResul t = mysql_query($in sertionQuery) or
    > die("La consulta de inserció n fall&oacute");
    >
    > The message I get is precisely: "La consulta de inserción falló"
    > (Insertion query failed, in english). And the php script dies.[/color]

    Also have a look at the message MySQL reports:

    $insertionResul t = mysql_query($in sertionQuery) or
    die("La consulta de inserció n falló"
    . ' con ' . mysql_error());
    --
    --= my mail box only accepts =--
    --= Content-Type: text/plain =--
    --= Size below 10001 bytes =--

    Comment

    • Alvaro G Vicario

      #3
      Re: Query not successful with PHP into MySQL

      *** Jaime Andres Aranguren Cardona wrote/escribió (2 Mar 2004 17:26:17
      -0800):[color=blue]
      > // Query execution
      > $insertionResul t = mysql_query($in sertionQuery) or
      > die("La consulta de inserció n fall&oacute");[/color]

      Two ideas to find out what's going on:

      echo '<p>'.htmlentit ies($insertionQ uery).'</p>';
      insertionResult = mysql_query($in sertionQuery) or
      die("La consulta de inserci&oacute; n fall&oacute: ".mysql_error() );

      --
      --
      -- Álvaro G. Vicario - Burgos, Spain
      --

      Comment

      • Jaime Andres Aranguren Cardona

        #4
        Re: Query not successful with PHP into MySQL

        Alvaro G Vicario <alvaro_QUITAR_ REMOVE@telecomp uteronline.com> wrote in message news:<1jw4ahzdf lxsi$.v8qxfd4lt 499.dlg@40tude. net>...[color=blue]
        > *** Jaime Andres Aranguren Cardona wrote/escribió (2 Mar 2004 17:26:17
        > -0800):[color=green]
        > > // Query execution
        > > $insertionResul t = mysql_query($in sertionQuery) or
        > > die("La consulta de inserci&oacute; n fall&oacute");[/color]
        >
        > Two ideas to find out what's going on:
        >
        > echo '<p>'.htmlentit ies($insertionQ uery).'</p>';
        > $insertionResul t = mysql_query($in sertionQuery) or
        > die("La consulta de inserci&oacute; n fall&oacute: ".mysql_error() );
        >
        > --[/color]

        What I get is "La consulta de inserción falló: Query was empty".

        Help me, please!!

        TIA

        JaaC

        Comment

        • Alvaro G Vicario

          #5
          Re: Query not successful with PHP into MySQL

          *** Jaime Andres Aranguren Cardona wrote/escribió (3 Mar 2004 07:07:58
          -0800):[color=blue]
          > What I get is "La consulta de inserción falló: Query was empty".[/color]

          Query failed because $insertionQuery variable is an empty string.


          --
          --
          -- Álvaro G. Vicario - Burgos, Spain
          --

          Comment

          • Jaime Andres Aranguren Cardona

            #6
            Re: Query not successful with PHP into MySQL

            jaime.aranguren @ieee.org (Jaime Andres Aranguren Cardona) wrote in message news:<14a86f87. 0403030707.7fb4 7cc8@posting.go ogle.com>...[color=blue]
            > Alvaro G Vicario <alvaro_QUITAR_ REMOVE@telecomp uteronline.com> wrote in message news:<1jw4ahzdf lxsi$.v8qxfd4lt 499.dlg@40tude. net>...[color=green]
            > > *** Jaime Andres Aranguren Cardona wrote/escribió (2 Mar 2004 17:26:17
            > > -0800):[color=darkred]
            > > > // Query execution
            > > > $insertionResul t = mysql_query($in sertionQuery) or
            > > > die("La consulta de inserci&oacute; n fall&oacute");[/color]
            > >
            > > Two ideas to find out what's going on:
            > >
            > > echo '<p>'.htmlentit ies($insertionQ uery).'</p>';
            > > $insertionResul t = mysql_query($in sertionQuery) or
            > > die("La consulta de inserci&oacute; n fall&oacute: ".mysql_error() );
            > >
            > > --[/color]
            >
            > What I get is "La consulta de inserción falló: Query was empty".[/color]

            I need your advice, please!

            TIA
            [color=blue]
            >
            > Help me, please!!
            >
            > TIA
            >
            > JaaC[/color]

            Comment

            • Markus Ernst

              #7
              Re: Query not successful with PHP into MySQL

              "Jaime Andres Aranguren Cardona" <jaime.arangure n@ieee.org> schrieb im
              Newsbeitrag news:14a86f87.0 403050557.19e2d 3c5@posting.goo gle.com...[color=blue]
              > jaime.aranguren @ieee.org (Jaime Andres Aranguren Cardona) wrote in message[/color]
              news:<14a86f87. 0403030707.7fb4 7cc8@posting.go ogle.com>...[color=blue][color=green]
              > > Alvaro G Vicario <alvaro_QUITAR_ REMOVE@telecomp uteronline.com> wrote in[/color][/color]
              message news:<1jw4ahzdf lxsi$.v8qxfd4lt 499.dlg@40tude. net>...[color=blue][color=green][color=darkred]
              > > > *** Jaime Andres Aranguren Cardona wrote/escribió (2 Mar 2004 17:26:17
              > > > -0800):
              > > > > // Query execution
              > > > > $insertionResul t = mysql_query($in sertionQuery) or
              > > > > die("La consulta de inserci&oacute; n fall&oacute");
              > > >
              > > > Two ideas to find out what's going on:
              > > >
              > > > echo '<p>'.htmlentit ies($insertionQ uery).'</p>';
              > > > $insertionResul t = mysql_query($in sertionQuery) or
              > > > die("La consulta de inserci&oacute; n fall&oacute: ".mysql_error() );
              > > >
              > > > --[/color]
              > >
              > > What I get is "La consulta de inserción falló: Query was empty".[/color]
              >
              > I need your advice, please![/color]

              I am not sure: is the second argument of mysql_query optional? I usually do

              $insertionResul t = mysql_query($in sertionQuery,$l ink);

              HTH
              Markus


              Comment

              Working...