variable empty after after posting a delete query

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

    variable empty after after posting a delete query

    The variable contains: delete from divisies where divisieid='1c'
    After posting it contains: delete from divisies where divisieid=

    So the part '1c' is magically lost! How is that possible?

    This is more or less the code in my form:

    $sqldel = "delete from divisies where divisieid='1c' ";
    echo"<form action=".$_SERV ER['PHP_SELF']." method='post' >\n";
    echo"<input class='serred' type=submit value='Verwijde ren'
    name='removecon firm' />\n";
    echo"<input type=hidden name=sqldel value='$sqldel' />\n";
    echo"</form>\n";


    In another part of the form I do this

    if isset( $_POST['sqldel'] )
    {
    $sqldel =$_POST['sqldel']
    echo $sqldel; // this prints: delete from divisies where divisieid=
    }

    I tried several things, like addslashes, stripslashes but nothing
    helps to pass my sql query correctly. Anyone?

    GB
  • Yves Brault

    #2
    Re: variable empty after after posting a delete query

    That's because of your line

    echo"<input type=hidden name=sqldel value='$sqldel' />\n";

    Once executed, you get:

    <input type=hidden name=sqldel value='delete from divisies where
    divisieid='1c' ' />



    "Boefje" < B_o_e_f_j_e@Hot mail.com (remove the underscores)> wrote in
    message news:pfm0qv4276 7bkaqi4cc942hij m14bha1cn@4ax.c om...[color=blue]
    > The variable contains: delete from divisies where divisieid='1c'
    > After posting it contains: delete from divisies where divisieid=
    >
    > So the part '1c' is magically lost! How is that possible?
    >
    > This is more or less the code in my form:
    >
    > $sqldel = "delete from divisies where divisieid='1c' ";
    > echo"<form action=".$_SERV ER['PHP_SELF']." method='post' >\n";
    > echo"<input class='serred' type=submit value='Verwijde ren'
    > name='removecon firm' />\n";
    > echo"<input type=hidden name=sqldel value='$sqldel' />\n";
    > echo"</form>\n";
    >
    >
    > In another part of the form I do this
    >
    > if isset( $_POST['sqldel'] )
    > {
    > $sqldel =$_POST['sqldel']
    > echo $sqldel; // this prints: delete from divisies where divisieid=
    > }
    >
    > I tried several things, like addslashes, stripslashes but nothing
    > helps to pass my sql query correctly. Anyone?
    >
    > GB[/color]


    Comment

    • Boefje

      #3
      Re: variable empty after after posting a delete query

      Tom Thackrey gave me the solution. Many thanks!

      The problem is you are using single quotes in your html value=' '
      which are
      being munged by the single quotes in your sql

      try

      echo"<input type=hidden name=sqldel value=\"$sqldel \" />\n";


      On Thu, 30 Oct 2003 01:23:38 +0100, Boefje < B_o_e_f_j_e@Hot mail.com
      (remove the underscores)> wrote:
      [color=blue]
      >The variable contains: delete from divisies where divisieid='1c'
      >After posting it contains: delete from divisies where divisieid=
      >
      >So the part '1c' is magically lost! How is that possible?
      >
      >This is more or less the code in my form:
      >
      >$sqldel = "delete from divisies where divisieid='1c' ";
      >echo"<form action=".$_SERV ER['PHP_SELF']." method='post' >\n";
      >echo"<input class='serred' type=submit value='Verwijde ren'
      >name='removeco nfirm' />\n";
      >echo"<input type=hidden name=sqldel value='$sqldel' />\n";
      >echo"</form>\n";
      >
      >
      >In another part of the form I do this
      >
      >if isset( $_POST['sqldel'] )
      >{
      >$sqldel =$_POST['sqldel']
      >echo $sqldel; // this prints: delete from divisies where divisieid=
      >}
      >
      >I tried several things, like addslashes, stripslashes but nothing
      >helps to pass my sql query correctly. Anyone?
      >
      >GB[/color]

      Comment

      • Markus Ernst

        #4
        Re: variable empty after after posting a delete query

        "Boefje" < B_o_e_f_j_e@Hot mail.com (remove the underscores)> schrieb im
        Newsbeitrag news:flp0qvsmrg 362hlclaeek4p3g b6lkdo7f5@4ax.c om...
        [color=blue]
        > echo"<input type=hidden name=sqldel value=\"$sqldel \" />\n";[/color]

        You could save yourself lots of escaping by embedding the PHP into HTML
        instead of vice versa:

        <input type="hidden" name="sqldel" value="<? echo $sqldel; ?>">

        --
        Markus


        Comment

        Working...