Sergeant wrote:i got all yall said to do then i get this message
im really new to this so thats why i dont understand this
Well, the last version you posted is missing this line, which was in your original post:
if(!get_magic_quotes_gpc())
Now, not having an "IF" but having an "ELSE" is a logic problem that PHP will definitely complain about ("unexpected T_ELSE, blah blah")....
You'll find many opinions on how to go about this, but I think most people would agree that improving the style (layout) of your code would go a long way towards helping when it's time to debug a script. My company style manual is something like this:
<?php
if ($somevar) {
do_something();
if ($someothervar) {
echo "I have another variable!";
}
} else {
do_nothing();
}
?>
The point being that every closing bracket is directly below the keyword that opened the conditional.
Your script, and leatherback's response above this one, use a "K&R" type style:
<?php
if ($somevar)
{
do_something();
if ($someothervar)
{
echo "I have another variable!";
}
}
else
{
do_nothing();
}
?>
The idea being that each conditional's bracket set aligns directly with itself.
Finally, realize that PHP is a very forgiving (even read "loose") language, and allows syntax that is similar to a number of other languages in order to be easy to learn for people coming from varied programming backgrounds. This means that you can used a conditional construction like this:
<?php
if ($foo)
bar();
echo "Yahoo!";
?>
with NO brackets for the conditional statement[1]. But I wouldn't recommend that for newbies. Lay out every loop, every conditional with curly braces, and line them up so you can see where the problems are....
🙂
[1]Note that this works for direct two line conditionals only... in the test code, PHP will run the echo() call regardless...(even if you indent it, heh, heh)....