I have 3 files 1) show_createtable.html 2) do_showfielddef.php 3) do_showtble.php
1) First file is for creating a new table for a data base, it is a fom with 2 input
Your for
loop is not terminated. You are missing a }
for ($i = 0; $i < count($_POST[field_name]); $i++) {
$sql .= $_POST[field_name][$i]." ".$_POST[field_type][$i];
}
And as pointed by others there is also a missing }
for the last if
statement:
if ($result) {
$msg = "< p>" .$_POST[table_name]." has been created!< /p>";
}
in your php.ini
(php configuration) change :
short_open_tag = Off
you opened php tag shortly at line 1
just find and replace all <? with <?php
This error message means that a control structure block isn’t closed properly. In your case the closing }
of some of your control structures like the for
loop or the last if
are missing.
You should use proper indentation and an editor that highlights bracket pairs to have a visual aid to avoid such errors.
$result = mysql_query($sql, $connection) or die(mysql_error());
if ($result) {
$msg = "<p>" .$_POST[table_name]." has been created!</p>";
}
you missing a }
in your last if statement, and your for loop is missing a }
too
for ($i = 0; $i < count($_POST[field_name]); $i++) {
$sql .= $_POST[field_name][$i]." ".$_POST[field_type][$i];
if ($_POST[field_length][$i] !="") {
$sql .=" (".$_POST[field_length][$i]."),";
} else {
$sql .=",";
}
}
Stylistic tip: Use HEREDOCs to assign blocks of text to a variable, instead of the hideous multi-line-with-tons-of-escaping-backslashes constructs you're using. They're far easier to read and less error prone if/when you happen to forget a \ somewhere and break the script with a parse error.
I just solved this error, after checking my code, I had no open tags/braces.
For me, I got this error when moving to a amazon server.
It turns out I needed to enable short_open_tag = On
in my php.ini
.
This solved this error for me.