Jump to content

Issue with Script


dual_alliance

Recommended Posts

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>&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>[/code]

What am l doing wrong?
Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.