dual_alliance Posted July 8, 2006 Share Posted July 8, 2006 I know it is a messy script but l'm still working on fixing it up. But l get this error:[quote]Parse error: syntax error, unexpected T_STRING in /home3/alli4nc3/public_html/guestbook1/install.php on line 134[/quote][code]<?php$gbn = $_POST["guestBookName"];$bgc = $_POST["bgColour"];$host1 = $_POST["host"];$username1 = $_POST["userName"];$password1 = $_POST["passWord"];$dbn = $_POST["dbName"];$dbtn = $_POST["dbtName"];if (!isset($_POST['submit'])) {?><html><head> <title>Installation Settings</title><head> <title>Please enter main password</title> <style type="text/css"> p {font-family: sans-serif; color: #FFFFFF; } h1 {font-family: sans-serif; color: #FFFFFF; text-align: center; font-size: 175% } body {background-color: #000000; } </style></head></head><body bgcolor="#000000"><h1>Installation Settings</h1><br /><p>Please make sure all the settings are correct.</p><table width="90%" border="1" align="center" cellpadding="0" cellspacing="1" bgcolor="#000000"><tr><form id="form1" name="form1" method="post" action=<?php echo $PHP_SELF; ?>><td><table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#000000"><tr> <td width="117"><p>Guestbook Name</p></td> <td width="14">:</td> <td width="357"><input name="guestBookName" type="text" id="guestBookName" size="40" /></td></tr><tr> <td>Background colour of Guestbook</td> <td>:</td> <td><input name="bgColour" type="text" id="bgColour" size="40" /></td></tr><tr> <td><p>MySQL Settings!</p></td></tr><tr> <td>Host (Usually 'localhost' if unsure ask your hosting company)</td> <td>:</td> <td><input name="host" type="text" id="host" size="40" /></td></tr><tr> <td valign="top">Username (Username for your database)</td> <td valign="top">:</td> <td><textarea name="userName" cols="50" rows="4" id="userName"></textarea></td></tr><tr> <td valign="top">Password (Password for your database)</td> <td valign="top">:</td> <td><textarea name="passWord" cols="50" rows="4" id="passWord"></textarea></td></tr><tr> <td valign="top">Database Name (Database Name)</td> <td valign="top">:</td> <td><textarea name="dbName" cols="50" rows="4" id="dbName"></textarea></td></tr><tr> <td valign="top">Table Name (In Database)</td> <td valign="top">:</td> <td><textarea name="dbtName" cols="50" rows="4" id="dbtName"></textarea></td></tr><tr> <td> </td> <td> </td> <td><input type="submit" name="submit" value="Submit" /> <input type="reset" name="Submit2" value="Reset" /></td></tr></table></td></form><?php}else{$connect = mysql_connect("$host1", "$username1", "$password1") or die("Could not connect : " . mysql_error());mysql_select_db("$dbn") or die("Could not select database");/* Performing SQL query */$query = CREATE TABLE '$dbtName' ('id' int(4) NOT NULL auto_increment,'name' varchar(65) NOT NULL default '','website' varchar(65) NOT NULL default '','email' varchar(65) NOT NULL default '','comment' longtext NOT NULL,'datetime' varchar(65) NOT NULL default '',PRIMARY KEY ('id'));$result = mysql_query($query) or die("Query failed : " . mysql_error());/* Closing connection */mysql_close($connect);echo "Query Succesful";$File = "confgSettings.php";$Handle = fopen($File, 'w');$Data = "/<?php/n ";fwrite($Handle, $Data);$Data = "/$header /= /"$gbn/"/;/n ";fwrite($Handle, $Data);$Data = "/$background /= /"$bgc/"/;/n ";fwrite($Handle, $Data);$Data = "/$host /= /"$host1/"/;/n ";fwrite($Handle, $Data);$Data = "/$username /= /"$username1/"/;/n ";fwrite($Handle, $Data);$Data = "$password /= /"$password1/"/;/n ";fwrite($Handle, $Data);$Data = "$db_name /= /"$dbn/"/;/n ";fwrite($Handle, $Data);$Data = "$tbl_name /= /"$dbtn/"/;/n ";fwrite($Handle, $Data);$Data = "?/>/n ";fwrite($Handle, $Data);print "Data Written";fclose($Handle); echo "Data written to file";echo "Please now delete this file, you can now use the guestbook";}?></body></html>[/code]What am l doing wrong? Link to comment https://forums.phpfreaks.com/topic/14023-issue-with-script/ Share on other sites More sharing options...
wildteen88 Posted July 8, 2006 Share Posted July 8, 2006 Your query code:[code]$query = CREATE TABLE '$dbtName' ('id' int(4) NOT NULL auto_increment,'name' varchar(65) NOT NULL default '','website' varchar(65) NOT NULL default '','email' varchar(65) NOT NULL default '','comment' longtext NOT NULL,'datetime' varchar(65) NOT NULL default '',PRIMARY KEY ('id'));[/code] needs to be in quotes like so:[code]$query = "CREATE TABLE '{$dbtName}' ('id' int(4) NOT NULL auto_increment,'name' varchar(65) NOT NULL default '','website' varchar(65) NOT NULL default '','email' varchar(65) NOT NULL default '','comment' longtext NOT NULL,'datetime' varchar(65) NOT NULL default '',PRIMARY KEY ('id'));";[/cofr][/code] Link to comment https://forums.phpfreaks.com/topic/14023-issue-with-script/#findComment-54764 Share on other sites More sharing options...
dual_alliance Posted July 8, 2006 Author Share Posted July 8, 2006 Thanks, but now there is just another error.[quote]Parse error: syntax error, unexpected T_VARIABLE in /home3/alli4nc3/public_html/guestbook1/install.php on line 158[/quote]I think it has to do with the way l am writing information to the file:[code]$Data = "/$header /= /"$gbn/"/;/n ";fwrite($Handle, $Data);[/code]Is there another way so l can write the variable to the file? Link to comment https://forums.phpfreaks.com/topic/14023-issue-with-script/#findComment-54768 Share on other sites More sharing options...
wildteen88 Posted July 8, 2006 Share Posted July 8, 2006 IN this case you are using the wrong slash, rather than using a forward slash /You should use a backslash \So your code should be this:[code]$Data = "\$header = \"$gbn\";\n";fwrite($Handle, $Data);[/code]Also you dont need to escape every character, only certain characters. Link to comment https://forums.phpfreaks.com/topic/14023-issue-with-script/#findComment-54770 Share on other sites More sharing options...
dual_alliance Posted July 8, 2006 Author Share Posted July 8, 2006 Ok thanks, the only reason l have done so many is because l need that information to go to a new file and then that file contains the variables used for the guestbook. Link to comment https://forums.phpfreaks.com/topic/14023-issue-with-script/#findComment-54772 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.