buchberg Posted February 18, 2012 Share Posted February 18, 2012 Need a little help with this code. I'm running Apache 2.21 / PHP 5.3.5 on Windows. This is a V6 application. I am running Windows 7. I am new, and trying to learn. What am I doing wrong in line 8 with the 'if' statement? The idea is to create a table in mySQL using a form interface. Thank you in advance. Parse error: syntax error, unexpected '{' in C:\website\do_createtable.php on line 8 <? $db_name="booster"; $connection=mysql("localhost", "user", "password") or die (mysql_error()); $db=mysql_select_db($db_name, $connection) or die (mysql_error()); $sql="CREATE TABLE $_POST[table_name] ("; 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 .= ","; } } $sql=substr($sql,0,-1); $sql .= ")"; Link to comment https://forums.phpfreaks.com/topic/257227-creating-form-in-php-to-insert-table-in-mysql-db/ Share on other sites More sharing options...
buchberg Posted February 18, 2012 Author Share Posted February 18, 2012 Solved it. Thanks....Mike Link to comment https://forums.phpfreaks.com/topic/257227-creating-form-in-php-to-insert-table-in-mysql-db/#findComment-1318532 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.