Jump to content


Photo

Issue with Script


  • Please log in to reply
4 replies to this topic

#1 dual_alliance

dual_alliance
  • Members
  • PipPipPip
  • Advanced Member
  • 140 posts
  • LocationNSW, Australia

Posted 08 July 2006 - 01:11 PM

I know it is a messy script but l'm still working on fixing it up.  But l get this error:

Parse error: syntax error, unexpected T_STRING in /home3/alli4nc3/public_html/guestbook1/install.php on line 134


<?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>&nbsp;</td>
	<td>&nbsp;</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>

What am l doing wrong?

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 08 July 2006 - 01:28 PM

Your query 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')
);
needs to be in quotes like so:
$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]


#3 dual_alliance

dual_alliance
  • Members
  • PipPipPip
  • Advanced Member
  • 140 posts
  • LocationNSW, Australia

Posted 08 July 2006 - 01:36 PM

Thanks, but now there is just another error.

Parse error: syntax error, unexpected T_VARIABLE in /home3/alli4nc3/public_html/guestbook1/install.php on line 158


I think it has to do with the way l am writing information to the file:

$Data = "/$header /= /"$gbn/"/;/n ";
fwrite($Handle, $Data);

Is there another way so l can write the variable to the file?

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 08 July 2006 - 01:45 PM

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:
$Data = "\$header = \"$gbn\";\n";
fwrite($Handle, $Data);
Also you dont need to escape every character, only certain characters.

#5 dual_alliance

dual_alliance
  • Members
  • PipPipPip
  • Advanced Member
  • 140 posts
  • LocationNSW, Australia

Posted 08 July 2006 - 01:55 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users