Is there a way to evaluate a php variable as code instead of a string?
$sql1 = mysql_query("SELECT * FROM form WHERE id='".$id."'");
while($row1 = mysql_fetch_array($sql1)){
$id1 =$row1["id"];
$name1 =$row1["name"];
$name1 = str_replace(' ', '', $name1);
$name1 = str_replace('-', '', $name1);
$errorline .= "".$_POST[$name1]."=='' || ";
}
$errors = "if(".$errorline."){";
$errors .= '$error=1}';
eval($errors);
echo $error;
I am able to make $errors look the way I want it to.:
if(=='' || =='' || =='' || =='' || =='' || =='' || =='' || =='' || =='' || =='' || =='' || =='' || ){$error=1}
Where before the "==" is a post variable, thats why its not showing. I need to know how I can change this to code instead of a variable. As you can see, I tried the "eval" function, but it gives a T_IS_EQUAL error.
Can anyone help? If I have to change my logic I will, but I think you probably get the point as to what I am trying to achieve. This is for error checking of a dynamically created form.