jaypizzy Posted April 22, 2007 Share Posted April 22, 2007 I have been trying to sort out the problem with the following code for the longest time. Any help to understand it would be much appreciated. thanks <?php $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/48099-you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds-to-your/ Share on other sites More sharing options...
Janus13 Posted April 22, 2007 Share Posted April 22, 2007 this line: $sql = "CREATE TABLE $_POST[table_name]("; should read something like this: $sql = "CREATE TABLE " . $_POST['table_name']; You dont need the ( either. Try that and see if that fixes it. Link to comment https://forums.phpfreaks.com/topic/48099-you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds-to-your/#findComment-235069 Share on other sites More sharing options...
shaymol Posted April 22, 2007 Share Posted April 22, 2007 Hi jay you are using $_POST[table_name] instead of $_POST['var_name'] try to fix all $_POST variable with quote. i think it should work Thanks ShaymoL Link to comment https://forums.phpfreaks.com/topic/48099-you-have-an-error-in-your-sql-syntax-check-the-manual-that-corresponds-to-your/#findComment-235070 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.