Thanks in advance, here is what is going on:
if(isset($_POST['submit']))
{
$var = $_GET['var'];
foreach((array)$_POST['content'] as $area => $contents)
{
$result = 'UPDATE $table SET '.$area.' = "'.mysql_real_escape_string(stripslashes($contents)).'" WHERE var = "'.$_GET['var'].'";';
mysql_query ($result);
}
$query = 'UPDATE $table SET '.
'title = "'.mysql_real_escape_string(stripslashes($_POST["title"])).'", '.
'template = "'.mysql_real_escape_string($_POST["templateid"]).'", '.
'description = "'.mysql_real_escape_string(stripslashes($_POST["description"])).'", '.
'keywords = "'.mysql_real_escape_string(stripslashes($_POST["keywords"])).'" '.
' WHERE var = "'.$_GET['var'].'";';
mysql_query ($query);// or die(mysql_error());
}
I am unable to get the if statement to go beyond the for each loop. It will not update the database with the $query mysql statement. It simple updates the table for everything inside the for each loop and then exists. Do I need to do an If while or else if? And I tried looking up php conditional statements, is there such a thing as and statements? Such as: If post submit do this AND this? That is essentially what I am trying to do, If post submit, do for each loop AND do $query.
Let me know if you need more information.
Well, is
$_POST['content']defined at all? In cases like this you may want to start debugging withprint_r($_POST)to see all values that you get.What you probably intended to do is:
Edit:
And you should really escape that
$_GET['var']as well as the$areain the loop!!! Escape ALL user input, always!!!