By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,051 Members | 1,221 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,051 IT Pros & Developers. It's quick & easy.

variable empty after after posting a delete query

P: n/a
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=".$_SERVER['PHP_SELF']." method='post' >\n";
echo"<input class='serred' type=submit value='Verwijderen'
name='removeconfirm' />\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
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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_*********@Hotmail.com (remove the underscores)> wrote in
message news:pf********************************@4ax.com...
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=".$_SERVER['PHP_SELF']." method='post' >\n";
echo"<input class='serred' type=submit value='Verwijderen'
name='removeconfirm' />\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

Jul 17 '05 #2

P: n/a
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_*********@Hotmail.com
(remove the underscores)> wrote:
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=".$_SERVER['PHP_SELF']." method='post' >\n";
echo"<input class='serred' type=submit value='Verwijderen'
name='removeconfirm' />\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


Jul 17 '05 #3

P: n/a
"Boefje" < B_*********@Hotmail.com (remove the underscores)> schrieb im
Newsbeitrag news:fl********************************@4ax.com...
echo"<input type=hidden name=sqldel value=\"$sqldel\" />\n";


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
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.