Jingles87 Posted August 19, 2009 Share Posted August 19, 2009 Hey guys... I wrote a script and for some reason I am not getting anything. Literally anything. I tried add a "test" line having it echo a word but even that doesn't work. I'm kind of stumped as to what would be the problem. I personally didn't notice any errors in my code but maybe you can point something out I've missed. If you don't see anything it's possible it's the database but I wanted to get a second opinion. Also, I realize that some people might have better ways of writing the stuff in my script but that's not what I'm looking for. I'm simply trying to get the code that I have to work. Thanks in advance. <?php $db_name = "salmen01_db"; $connection = mysql_connect("localhost","admin","pass") 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[auto_increment][$i] == "Y"){ $additional = "NOT NULL auto_increment"; } else { $additional = ""; }//end if statement if($_POST[primary][$i] == "Y"){ $additional .= ", primary key (".$_POST[field_name][$i].")"; } else { $additional = ""; }//end if statement if($_POST[field_length][$i] != "") { $sql .= " (".$_POST[field_length][$i].") $additional ,"; } else { $sql .= " $additional ,"; }//end if statement }//end for statement $sql = substr($sql, 0, 1); $sql .= ")"; $result = mysql_query($sql, $connection) or die (mysql_error()); if($result){ $msg = "<p>".$_POST[table_name]." has been created!</p>"; } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Create a database table: step 3</title> </head> <body> </body> <?php echo "$msg"; ?> </html> Link to comment https://forums.phpfreaks.com/topic/171037-solved-unknown-problem/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 19, 2009 Share Posted August 19, 2009 Your code contains a fatal parse error - Parse error: parse error, expecting `')'' in yourfile.php on line 6 You should be learning php, developing php code, and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON in your php.ini to get php to help you. Stop and start your web server to get any change made to php.ini to take effect. Link to comment https://forums.phpfreaks.com/topic/171037-solved-unknown-problem/#findComment-902060 Share on other sites More sharing options...
suresh64633 Posted August 20, 2009 Share Posted August 20, 2009 You just miss '$' sign before your variable in line 6. Link to comment https://forums.phpfreaks.com/topic/171037-solved-unknown-problem/#findComment-902459 Share on other sites More sharing options...
Jingles87 Posted August 25, 2009 Author Share Posted August 25, 2009 Thanks for the tip(s). I was able to solve my problem. I had a few syntax errors and my username and password for my database was wrong. Link to comment https://forums.phpfreaks.com/topic/171037-solved-unknown-problem/#findComment-905952 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.