PDA

View Full Version : My Install File



adamFTW
14-12-2007, 11:10 PM
Well, this is my first ever try at making an install file, and it isn't going too well. I have the following code:


<?
include "iconfig.php";

// DO NOT edit the following unless you know what you are doing
if ($_GET['step'] == '1') {
$query = mysql_query("CREATE TABLE `users` (
`uid` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(50) NOT NULL,
`password` varchar(500) NOT NULL,
PRIMARY KEY (`uid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;");

$query = mysql_query("CREATE TABLE `petition` (
`id` INT( 20 ) NOT NULL AUTO_INCREMENT ,
`name` VARCHAR( 30 ) NOT NULL ,
`other` VARCHAR( 30 ) NOT NULL ,
`comment` VARCHAR( 200 ) NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM");

$query = mysql_query("CREATE TABLE `admin` (
`navigation` TEXT( 10000 ) NOT NULL ,
`maincontent` TEXT( 10000 ) NOT NULL ,
`php` TEXT( 10000 ) NOT NULL ,
`other` TEXT( 10000 ) NOT NULL ,
`footer` VARCHAR( 10000 ) NOT NULL
) ENGINE = MYISAM");

$query = mysql_query("CREATE TABLE `home` (
`navigation` TEXT( 10000 ) NOT NULL ,
`maincontent` TEXT( 10000 ) NOT NULL ,
`php` TEXT( 10000 ) NOT NULL ,
`other` TEXT( 10000 ) NOT NULL ,
`footer` TEXT( 10000 ) NOT NULL
) ENGINE = MYISAM");

$query = mysql_query("CREATE TABLE `other` (
`navigation` TEXT( 10000 ) NOT NULL ,
`maincontent` TEXT( 10000 ) NOT NULL ,
`php` TEXT( 10000 ) NOT NULL ,
`other` TEXT( 10000 ) NOT NULL ,
`footer` TEXT( 10000 ) NOT NULL
) ENGINE = MYISAM");

$query = mysql_query("CREATE TABLE `sign` (
`navigation` TEXT( 10000 ) NOT NULL ,
`maincontent` TEXT( 10000 ) NOT NULL ,
`php` TEXT( 10000 ) NOT NULL ,
`other` TEXT( 10000 ) NOT NULL ,
`footer` TEXT( 10000 ) NOT NULL
) ENGINE = MYISAM");

$query = mysql_query("CREATE TABLE `view` (
`navigation` TEXT( 10000 ) NOT NULL ,
`maincontent` TEXT( 10000 ) NOT NULL ,
`php` TEXT( 10000 ) NOT NULL ,
`other` TEXT( 10000 ) NOT NULL ,
`footer` TEXT( 10000 ) NOT NULL
) ENGINE = MYISAM");

$query = mysql_query("CREATE TABLE `titles` (
`home` TEXT( 10000 ) NOT NULL ,
`sign` TEXT( 10000 ) NOT NULL ,
`view` TEXT( 10000 ) NOT NULL ,
`other` TEXT( 10000 ) NOT NULL
) ENGINE = MYISAM");

$query = mysql_query("INSERT INTO `admin` (`navigation`, `maincontent`, `php`, `other`, `footer`) VALUES (Home | <a href=\"edit.php\">View + Edit Comments / Other Details</a> | <a href=\"editpage.php\">Edit Pages</a> | <a href=\"editsite.php\">Edit Site Details</a>, Welcome to the administration panel, use the links above to navigate your way through the panel., This is optional PHP, you don't really need it for the admin CP main page., This is where you put any other stuff, you can edit all of this using the Edit Site Pages link., Footer BBZ. Add your copyright etc. here.);");

$query = mysql_query("INSERT INTO `home` (`navigation`, `maincontent`, `php`, `other`, `footer`) VALUES (Home | <a href=\"sign.php\">Sign</a> <a href=\"view.php\">View Entries</a> | <a href=\"other.php\">Other</a>, Welcome! Edit all this text in the admin CP., This is optional PHP, you don't really need it for the main page., This is where you put any other stuff, you can edit all of this using the Edit Site Pages link., Footer BBZ. Add your copyright etc. here.);");

$query = mysql_query("INSERT INTO `sign` (`navigation`, `maincontent`, `php`, `other`, `footer`) VALUES (<a href=\"index.php\">Home</a> | Sign <a href=\"view.php\">View Entries</a> | <a href=\"other.php\">Other</a>, Welcome! Edit all this text in the admin CP. This is NOT where you stick the form, etc., <?php
// The database
include 'config.php';

// The variables
$name = ($_POST[\"name\"]);
$other = ($_POST[\"other\"]);
$comment = ($_POST[\"comment\"]);
$ip = $_SERVER[REMOTE_ADDR];

//Those horrible IF's - Form data
if ($_GET[\"action\"] == \"submit\")
{
if ($name == "")
{
echo \"Whoops! You didn't enter your name.\";
exit;
}


if ($comment== "")
{
echo \"Whoops! You didnt enter a comment.\";
exit;
}
$name = addslashes(htmlspecialchars($name));
$grade = addslashes(htmlspecialchars($grade));
$comment = addslashes(htmlspecialchars($comment));
$addpetition = mysql_query(\"INSERT INTO `petition` (`name`, `other`, `comment`, `ip`) VALUES ('$name','$other','$comment', '$ip')\");

// The form details are fine, display text & details
echo \"Thank you for signing the petition! Here are the details you submitted: <br />
Name: $name<br />
Other: $other<br />
Your comment: $comment<br />
<br />
To view all the signatures, click <a href=\"view.php\">here.</a> To go back to the home page, click <a href=\"index.php\">here.</a>\";
exit;
}

else
// Display the form
{
echo \"
<div align\"center\">Want Miss Oppedisano to stay at O.L.H? Sign the petition below. Your support is needed.<br />
<strong>Remember, only sign the petition once!</strong></div><br />
<br />
<form action=\"?action=submit\" method=\"post\">
<div id=\"title\">Name:</div>
<input type=\"text\" name=\"name\"><br /><br />
<div id=\"title\">Other (EDIT IN ADMIN CP):</div>
<input type=\"text\" name=\"other\"><br /><br />
<div id=\"title\">Comment:</div>
<style=\"width=\"169\"; height=\"116\"><textarea rows=\"7\" input type=\"text\" name=\"comment\" cols=\"28\"></textarea><br />
<input type=\"submit\" name=\"submit\" value=\"Sign the petition!\">
</form>\";
exit;
}

?>, This is where you put any other stuff, you can edit all of this using the Edit Site Pages link., Footer BBZ. Add your copyright etc. here.);");
exit;
}

$query = mysql_query("INSERT INTO `view` (`navigation`, `maincontent`, `php`, `other`, `footer`) VALUES (<a href=\"index.php\">Home</a> | <a href=\"sign.php\">Sign</a> View Entries | <a href=\"other.php\">Other</a>, Welcome! Edit all this text in the admin CP. This is NOT where you stick the form, etc., <?php
//DB connection
include \"config.php\";

// Display number of entries
$query = mysql_query(\"select count(*) from petition\");
$result = mysql_result($query, 0);
echo \"We have a total of <strong>$result</strong> signatures!\";
?>
<?php
// The database connetcion
include \"config.php\";

$sql = \"SELECT * FROM petition\";
$check = mysql_query(\"SELECT name, other, comment FROM petition\") or die(\"Sorry, the data couldn't be displayed. Please check back later.\");
// The above variables will be used to check our connection to MySQL.

while ($display = mysql_fetch_array($check)) {

$name = $display['name'];
$other = $display['other'];
$comment = $display['comment'];

// Above are variables defined for our Name, Gradeand Comment.

echo \"
<strong>Name:</strong> $name
<br>
<strong>Other:</strong> $other
<br>
<strong>Comment:</strong><br>$comment
<br>
__________________________________________________ __________<br /><br />
\";

}
?>, This is where you put any other stuff, you can edit all of this using the Edit Site Pages link., Footer BBZ. Add your copyright etc. here.);");

$query = mysql_query("INSERT INTO `other` (`navigation`, `maincontent`, `php`, `other`, `footer`) VALUES (<a href=\"index.php\">Home</a> | <a href=\"sign.php\">Sign</a> <a href=\"view.php\">View Entries</a> | Other, Welcome! Edit all this text in the admin CP. This is NOT where you stick the form, etc., This is optional PHP, you don't really need it for the other page. But it is other, so add whatever you want here., This is where you put any other stuff, you can edit all of this in the admin CP., Footer BBZ. Add your copyright etc. here.);");

echo ("Step 1 done! Now, please enter your desired username and password for admin CP.<br />

<form action=\"?step=2\" method=\"post\">
Username:<br />
<input type=\"text\" name=\"name\"><br />
Password:<br />
<input type=\"text\" name=\"password\"><br />
<input type=\"submit\" name=\"start\" value=\"Step 2\"></form>");
};

$user = ($_POST["username"]);
$pass = ($_POST["password"]);
$pass = md5($password);

elseif ($_GET['step'] == '2') {
$query = mysql_query("INSERT INTO `users` ( `uid` , `username` , `password` ) VALUES ( NULL, ‘$user’, ‘$pass‘ )");
};

else ("Welcome to the erPETITION v0.1 installer! This will add all the necessary databases and codes into your mySQL DB. Before you continue, <strong>please</strong> make sure your database info is correct.
Host: $db[host] <br>Username: $db[user] <br>Password: $db[pass] <br> Database: $db[name]<br />
If your database info is incorrect, please go and edit config.php now.<br />
<form action=\"?step=1\" method=\"post\"><input type=\"submit\" name=\"start\" value=\"Step 1\"></form>");

?>I get the following error when viewing it:


Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/deano/public_html/admin/install.php on line 85Line 85 is:
$name = ($_POST[\"name\"]);I'm pretty sure somebody knows the problem, as I've experimented and cannot figure out how to fix it. And, if you're nice enough/have the time, do you mind cleaning up the code a little?

Thanks. +rep to any help.

P.S.: The post editor doesnt let me add the beginning slash to
$name = ($_POST[\"name\"]) There is suppose to be a "\" before "name\", but it doesn't show up.

Moved by Agesilaus (Forum Moderator) from Design and Development: Please post in the correct forum in future.

abnormal
14-12-2007, 11:12 PM
Well, this is my first ever try at making an install file, and it isn't going too well. I have the following code:


<?
include "iconfig.php";

// DO NOT edit the following unless you know what you are doing
if ($_GET['step'] == '1') {
$query = mysql_query("CREATE TABLE `users` (
`uid` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(50) NOT NULL,
`password` varchar(500) NOT NULL,
PRIMARY KEY (`uid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;");

$query = mysql_query("CREATE TABLE `petition` (
`id` INT( 20 ) NOT NULL AUTO_INCREMENT ,
`name` VARCHAR( 30 ) NOT NULL ,
`other` VARCHAR( 30 ) NOT NULL ,
`comment` VARCHAR( 200 ) NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM");

$query = mysql_query("CREATE TABLE `admin` (
`navigation` TEXT( 10000 ) NOT NULL ,
`maincontent` TEXT( 10000 ) NOT NULL ,
`php` TEXT( 10000 ) NOT NULL ,
`other` TEXT( 10000 ) NOT NULL ,
`footer` VARCHAR( 10000 ) NOT NULL
) ENGINE = MYISAM");

$query = mysql_query("CREATE TABLE `home` (
`navigation` TEXT( 10000 ) NOT NULL ,
`maincontent` TEXT( 10000 ) NOT NULL ,
`php` TEXT( 10000 ) NOT NULL ,
`other` TEXT( 10000 ) NOT NULL ,
`footer` TEXT( 10000 ) NOT NULL
) ENGINE = MYISAM");

$query = mysql_query("CREATE TABLE `other` (
`navigation` TEXT( 10000 ) NOT NULL ,
`maincontent` TEXT( 10000 ) NOT NULL ,
`php` TEXT( 10000 ) NOT NULL ,
`other` TEXT( 10000 ) NOT NULL ,
`footer` TEXT( 10000 ) NOT NULL
) ENGINE = MYISAM");

$query = mysql_query("CREATE TABLE `sign` (
`navigation` TEXT( 10000 ) NOT NULL ,
`maincontent` TEXT( 10000 ) NOT NULL ,
`php` TEXT( 10000 ) NOT NULL ,
`other` TEXT( 10000 ) NOT NULL ,
`footer` TEXT( 10000 ) NOT NULL
) ENGINE = MYISAM");

$query = mysql_query("CREATE TABLE `view` (
`navigation` TEXT( 10000 ) NOT NULL ,
`maincontent` TEXT( 10000 ) NOT NULL ,
`php` TEXT( 10000 ) NOT NULL ,
`other` TEXT( 10000 ) NOT NULL ,
`footer` TEXT( 10000 ) NOT NULL
) ENGINE = MYISAM");

$query = mysql_query("CREATE TABLE `titles` (
`home` TEXT( 10000 ) NOT NULL ,
`sign` TEXT( 10000 ) NOT NULL ,
`view` TEXT( 10000 ) NOT NULL ,
`other` TEXT( 10000 ) NOT NULL
) ENGINE = MYISAM");

$query = mysql_query("INSERT INTO `admin` (`navigation`, `maincontent`, `php`, `other`, `footer`) VALUES (Home | <a href=\"edit.php\">View + Edit Comments / Other Details</a> | <a href=\"editpage.php\">Edit Pages</a> | <a href=\"editsite.php\">Edit Site Details</a>, Welcome to the administration panel, use the links above to navigate your way through the panel., This is optional PHP, you don't really need it for the admin CP main page., This is where you put any other stuff, you can edit all of this using the Edit Site Pages link., Footer BBZ. Add your copyright etc. here.);");

$query = mysql_query("INSERT INTO `home` (`navigation`, `maincontent`, `php`, `other`, `footer`) VALUES (Home | <a href=\"sign.php\">Sign</a> <a href=\"view.php\">View Entries</a> | <a href=\"other.php\">Other</a>, Welcome! Edit all this text in the admin CP., This is optional PHP, you don't really need it for the main page., This is where you put any other stuff, you can edit all of this using the Edit Site Pages link., Footer BBZ. Add your copyright etc. here.);");

$query = mysql_query("INSERT INTO `sign` (`navigation`, `maincontent`, `php`, `other`, `footer`) VALUES (<a href=\"index.php\">Home</a> | Sign <a href=\"view.php\">View Entries</a> | <a href=\"other.php\">Other</a>, Welcome! Edit all this text in the admin CP. This is NOT where you stick the form, etc., <?php
// The database
include 'config.php';

// The variables
$name = ($_POST[\"name\"]);
$other = ($_POST[\"other\"]);
$comment = ($_POST[\"comment\"]);
$ip = $_SERVER[REMOTE_ADDR];

//Those horrible IF's - Form data
if ($_GET[\"action\"] == \"submit\")
{
if ($name == "")
{
echo \"Whoops! You didn't enter your name.\";
exit;
}


if ($comment== "")
{
echo \"Whoops! You didnt enter a comment.\";
exit;
}
$name = addslashes(htmlspecialchars($name));
$grade = addslashes(htmlspecialchars($grade));
$comment = addslashes(htmlspecialchars($comment));
$addpetition = mysql_query(\"INSERT INTO `petition` (`name`, `other`, `comment`, `ip`) VALUES ('$name','$other','$comment', '$ip')\");

// The form details are fine, display text & details
echo \"Thank you for signing the petition! Here are the details you submitted: <br />
Name: $name<br />
Other: $other<br />
Your comment: $comment<br />
<br />
To view all the signatures, click <a href=\"view.php\">here.</a> To go back to the home page, click <a href=\"index.php\">here.</a>\";
exit;
}

else
// Display the form
{
echo \"
<div align\"center\">Want Miss Oppedisano to stay at O.L.H? Sign the petition below. Your support is needed.<br />
<strong>Remember, only sign the petition once!</strong></div><br />
<br />
<form action=\"?action=submit\" method=\"post\">
<div id=\"title\">Name:</div>
<input type=\"text\" name=\"name\"><br /><br />
<div id=\"title\">Other (EDIT IN ADMIN CP):</div>
<input type=\"text\" name=\"other\"><br /><br />
<div id=\"title\">Comment:</div>
<style=\"width=\"169\"; height=\"116\"><textarea rows=\"7\" input type=\"text\" name=\"comment\" cols=\"28\"></textarea><br />
<input type=\"submit\" name=\"submit\" value=\"Sign the petition!\">
</form>\";
exit;
}

?>, This is where you put any other stuff, you can edit all of this using the Edit Site Pages link., Footer BBZ. Add your copyright etc. here.);");
exit;
}

$query = mysql_query("INSERT INTO `view` (`navigation`, `maincontent`, `php`, `other`, `footer`) VALUES (<a href=\"index.php\">Home</a> | <a href=\"sign.php\">Sign</a> View Entries | <a href=\"other.php\">Other</a>, Welcome! Edit all this text in the admin CP. This is NOT where you stick the form, etc., <?php
//DB connection
include \"config.php\";

// Display number of entries
$query = mysql_query(\"select count(*) from petition\");
$result = mysql_result($query, 0);
echo \"We have a total of <strong>$result</strong> signatures!\";
?>
<?php
// The database connetcion
include \"config.php\";

$sql = \"SELECT * FROM petition\";
$check = mysql_query(\"SELECT name, other, comment FROM petition\") or die(\"Sorry, the data couldn't be displayed. Please check back later.\");
// The above variables will be used to check our connection to MySQL.

while ($display = mysql_fetch_array($check)) {

$name = $display['name'];
$other = $display['other'];
$comment = $display['comment'];

// Above are variables defined for our Name, Gradeand Comment.

echo \"
<strong>Name:</strong> $name
<br>
<strong>Other:</strong> $other
<br>
<strong>Comment:</strong><br>$comment
<br>
__________________________________________________ __________<br /><br />
\";

}
?>, This is where you put any other stuff, you can edit all of this using the Edit Site Pages link., Footer BBZ. Add your copyright etc. here.);");

$query = mysql_query("INSERT INTO `other` (`navigation`, `maincontent`, `php`, `other`, `footer`) VALUES (<a href=\"index.php\">Home</a> | <a href=\"sign.php\">Sign</a> <a href=\"view.php\">View Entries</a> | Other, Welcome! Edit all this text in the admin CP. This is NOT where you stick the form, etc., This is optional PHP, you don't really need it for the other page. But it is other, so add whatever you want here., This is where you put any other stuff, you can edit all of this in the admin CP., Footer BBZ. Add your copyright etc. here.);");

echo ("Step 1 done! Now, please enter your desired username and password for admin CP.<br />

<form action=\"?step=2\" method=\"post\">
Username:<br />
<input type=\"text\" name=\"name\"><br />
Password:<br />
<input type=\"text\" name=\"password\"><br />
<input type=\"submit\" name=\"start\" value=\"Step 2\"></form>");
};

$user = ($_POST["username"]);
$pass = ($_POST["password"]);
$pass = md5($password);

elseif ($_GET['step'] == '2') {
$query = mysql_query("INSERT INTO `users` ( `uid` , `username` , `password` ) VALUES ( NULL, ‘$user’, ‘$pass‘ )");
};

else ("Welcome to the erPETITION v0.1 installer! This will add all the necessary databases and codes into your mySQL DB. Before you continue, <strong>please</strong> make sure your database info is correct.
Host: $db[host] <br>Username: $db[user] <br>Password: $db[pass] <br> Database: $db[name]<br />
If your database info is incorrect, please go and edit config.php now.<br />
<form action=\"?step=1\" method=\"post\"><input type=\"submit\" name=\"start\" value=\"Step 1\"></form>");

?>I get the following error when viewing it:
Line 85 is:
$name = ($_POST[\"name\"]);I'm pretty sure somebody knows the problem, as I've experimented and cannot figure out how to fix it. And, if you're nice enough/have the time, do you mind cleaning up the code a little?

Thanks. +rep to any help.


<?
include "iconfig.php";</SPAN></SPAN>

changed to...


<?
include "config.php";</SPAN></SPAN>

possibly?

adamFTW
14-12-2007, 11:13 PM
Nope, it's suppose to be iconfig.php. Thanks though. +rep.

Anybody else know what's up?

Invent
14-12-2007, 11:16 PM
I'll fix it in a sec.

adamFTW
14-12-2007, 11:31 PM
I'll fix it in a sec.

Thank you. ^_^

Ini
14-12-2007, 11:47 PM
If you dont mind me asking why do you have one include "iconfig.php"; and two include "config.php";

?

adamFTW
14-12-2007, 11:50 PM
If you dont mind me asking why do you have one include "iconfig.php"; and two include "config.php";

?

Those are being inserted into a mySQL database, and that will be displayed as PHP code on a webpage. It's suppose to be there. Thanks for trying, +rep.

Hitman
14-12-2007, 11:52 PM
ohh poop, shoudl there be the\'s in front of every "? i thought it was only ion echos when you use html

maybe name should be ['name']

(sorry if im wrong im peed.)

adamFTW
14-12-2007, 11:57 PM
ohh poop, shoudl there be the\'s in front of every "? i thought it was only ion echos when you use html

maybe name should be ['name']

(sorry if im wrong im peed.)

I do use "\"s, at least I believe I have done it for everything. If I haven't, could you please show me where?

Hitman
15-12-2007, 12:02 AM
Hi Adam,

You have things like

$query = mysql_query(\"select count(*) from petition\");
$result = mysql_result($query, 0);
there shouldn't be any \ before " when it's pure PHP. If it's an HTML echo (ie echo "<input type=\"text\"> then there should, but on a query (ie query = mysql_query(\"INSTER INTO......\") there shouldn't be \.

I'm not sure if it effects the script, but it isn't needed.

Might be the cause, I really don't know but I do know it doesn't need to be there.

Good luck mate! :D

adamFTW
15-12-2007, 12:05 AM
Hi Adam,

You have things like

$query = mysql_query(\"select count(*) from petition\");
$result = mysql_result($query, 0);
there shouldn't be any \ before " when it's pure PHP. If it's an HTML echo (ie echo "<input type=\"text\"> then there should, but on a query (ie query = mysql_query(\"INSTER INTO......\") there shouldn't be \.

I'm not sure if it effects the script, but it isn't needed.

Might be the cause, I really don't know but I do know it doesn't need to be there.

Good luck mate! :D


The reason being is because those things are inside quotation marks, therefore, needing "\"s. If that makes any sense.

Hitman
15-12-2007, 12:07 AM
OK, I've lost it im drunk off my head xD

I will reply tomorrow wirh a decent reply...:P

Just try changing the $_POST["name\"] to $_POST['name']

Cya tomorrow dude!!

adamFTW
15-12-2007, 12:09 AM
OK, I've lost it im drunk off my head xD

I will reply tomorrow wirh a decent reply...:P

Just try changing the $_POST["name\"] to $_POST['name']

Cya tomorrow dude!!

I'll try, thank you! +rep.

EDIT: I tried, but it still doesn't work. :(

Hitman
15-12-2007, 09:52 AM
Right, I'm sober now haha. :P

The code is very bad. Why are there random ?>'s and things that are dividing the script up? Also all the \'s before the "'s aren't needed, they're only needed when you're echoing HTML (ie <input type=\"text\">).

I tried to fix it - it's a big mess though, one error after another.

Here's what I fixed up if anybody wants to fix it on from there.


<?
include "iconfig.php";

// DO NOT edit the following unless you know what you are doing
if ($_GET['step'] == '1') {
$query = mysql_query("CREATE TABLE `users` (
`uid` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(50) NOT NULL,
`password` varchar(500) NOT NULL,
PRIMARY KEY (`uid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;");

$query = mysql_query("CREATE TABLE `petition` (
`id` INT( 20 ) NOT NULL AUTO_INCREMENT ,
`name` VARCHAR( 30 ) NOT NULL ,
`other` VARCHAR( 30 ) NOT NULL ,
`comment` VARCHAR( 200 ) NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM");

$query = mysql_query("CREATE TABLE `admin` (
`navigation` TEXT( 10000 ) NOT NULL ,
`maincontent` TEXT( 10000 ) NOT NULL ,
`php` TEXT( 10000 ) NOT NULL ,
`other` TEXT( 10000 ) NOT NULL ,
`footer` VARCHAR( 10000 ) NOT NULL
) ENGINE = MYISAM");

$query = mysql_query("CREATE TABLE `home` (
`navigation` TEXT( 10000 ) NOT NULL ,
`maincontent` TEXT( 10000 ) NOT NULL ,
`php` TEXT( 10000 ) NOT NULL ,
`other` TEXT( 10000 ) NOT NULL ,
`footer` TEXT( 10000 ) NOT NULL
) ENGINE = MYISAM");

$query = mysql_query("CREATE TABLE `other` (
`navigation` TEXT( 10000 ) NOT NULL ,
`maincontent` TEXT( 10000 ) NOT NULL ,
`php` TEXT( 10000 ) NOT NULL ,
`other` TEXT( 10000 ) NOT NULL ,
`footer` TEXT( 10000 ) NOT NULL
) ENGINE = MYISAM");

$query = mysql_query("CREATE TABLE `sign` (
`navigation` TEXT( 10000 ) NOT NULL ,
`maincontent` TEXT( 10000 ) NOT NULL ,
`php` TEXT( 10000 ) NOT NULL ,
`other` TEXT( 10000 ) NOT NULL ,
`footer` TEXT( 10000 ) NOT NULL
) ENGINE = MYISAM");

$query = mysql_query("CREATE TABLE `view` (
`navigation` TEXT( 10000 ) NOT NULL ,
`maincontent` TEXT( 10000 ) NOT NULL ,
`php` TEXT( 10000 ) NOT NULL ,
`other` TEXT( 10000 ) NOT NULL ,
`footer` TEXT( 10000 ) NOT NULL
) ENGINE = MYISAM");

$query = mysql_query("CREATE TABLE `titles` (
`home` TEXT( 10000 ) NOT NULL ,
`sign` TEXT( 10000 ) NOT NULL ,
`view` TEXT( 10000 ) NOT NULL ,
`other` TEXT( 10000 ) NOT NULL
) ENGINE = MYISAM");

$query = mysql_query("INSERT INTO `admin` (`navigation`, `maincontent`, `php`, `other`, `footer`) VALUES (Home | <a href=\"edit.php\">View + Edit Comments / Other Details</a> | <a href=\"editpage.php\">Edit Pages</a> | <a href=\"editsite.php\">Edit Site Details</a>, Welcome to the administration panel, use the links above to navigate your way through the panel., This is optional PHP, you don't really need it for the admin CP main page., This is where you put any other stuff, you can edit all of this using the Edit Site Pages link., Footer BBZ. Add your copyright etc. here.);");

$query = mysql_query("INSERT INTO `home` (`navigation`, `maincontent`, `php`, `other`, `footer`) VALUES (Home | <a href=\"sign.php\">Sign</a> <a href=\"view.php\">View Entries</a> | <a href=\"other.php\">Other</a>, Welcome! Edit all this text in the admin CP., This is optional PHP, you don't really need it for the main page., This is where you put any other stuff, you can edit all of this using the Edit Site Pages link., Footer BBZ. Add your copyright etc. here.);");

$query = mysql_query("INSERT INTO `sign` (`navigation`, `maincontent`, `php`, `other`, `footer`) VALUES (<a href=\"index.php\">Home</a> | Sign <a href=\"view.php\">View Entries</a> | <a href=\"other.php\">Other</a>, Welcome! Edit all this text in the admin CP. This is NOT where you stick the form, etc.");
// The database
include 'config.php';

// The variables
$name = $_POST["name"];
$other = $_POST["other"];
$comment = $_POST["comment"];
$ip = $_SERVER[REMOTE_ADDR];

//Those horrible IF's - Form data
if ($_GET["action"] == "submit")
{
if ($name == "")
{
echo "Whoops! You didn't enter your name.";
exit;
}


if ($comment== "")
{
echo "Whoops! You didnt enter a comment.";
exit;
}
$name = addslashes(htmlspecialchars($name));
$grade = addslashes(htmlspecialchars($grade));
$comment = addslashes(htmlspecialchars($comment));
$addpetition = mysql_query("INSERT INTO `petition` (`name`, `other`, `comment`, `ip`) VALUES ('$name','$other','$comment', '$ip')");

// The form details are fine, display text & details
echo "Thank you for signing the petition! Here are the details you submitted: <br />
Name: $name<br />
Other: $other<br />
Your comment: $comment<br />
<br />
To view all the signatures, click <a href=\"view.php\">here.</a> To go back to the home page, click <a href=\"index.php\">here.</a>";
exit;
}

else
// Display the form
{
echo "
<div align=\"center\">Want Miss Oppedisano to stay at O.L.H? Sign the petition below. Your support is needed.<br />
<strong>Remember, only sign the petition once!</strong></div><br />
<br />
<form action=\"?action=submit\" method=\"post\">
<div id=\"title\">Name:</div>
<input type=\"text\" name=\"name\"><br /><br />
<div id=\"title\">Other (EDIT IN ADMIN CP):</div>
<input type=\"text\" name=\"other\"><br /><br />
<div id=\"title\">Comment:</div>
<style=\"width=\"169\"; height=\"116\"><textarea rows=\"7\" input type=\"text\" name=\"comment\" cols=\"28\"></textarea><br />
<input type=\"submit\" name=\"submit\" value=\"Sign the petition!\">
</form>";
exit;
}

?>, This is where you put any other stuff, you can edit all of this using the Edit Site Pages link., Footer BBZ. Add your copyright etc. here.);");
exit;
}

$query = mysql_query("INSERT INTO `view` (`navigation`, `maincontent`, `php`, `other`, `footer`) VALUES (<a href=\"index.php\">Home</a> | <a href=\"sign.php\">Sign</a> View Entries | <a href=\"other.php\">Other</a>, Welcome! Edit all this text in the admin CP. This is NOT where you stick the form, etc., <?php
//DB connection
include "config.php";

// Display number of entries
$query = mysql_query("select count(*) from petition");
$result = mysql_result($query, 0);
echo "We have a total of <strong>$result</strong> signatures!";
?>
<?php
// The database connetcion
include "config.php";

$sql = "SELECT * FROM petition";
$check = mysql_query("SELECT name, other, comment FROM petition") or die("Sorry, the data couldn't be displayed. Please check back later.");
// The above variables will be used to check our connection to MySQL.

while ($display = mysql_fetch_array($check)) {

$name = $display['name'];
$other = $display['other'];
$comment = $display['comment'];

// Above are variables defined for our Name, Gradeand Comment.

echo "
<strong>Name:</strong> $name
<br>
<strong>Other:</strong> $other
<br>
<strong>Comment:</strong><br>$comment
<br>
__________________________________________________ __________<br /><br />
";

}
?>This is where you put any other stuff, you can edit all of this using the Edit Site Pages link., Footer BBZ. Add your copyright etc. here.);");

$query = mysql_query("INSERT INTO `other` (`navigation`, `maincontent`, `php`, `other`, `footer`) VALUES (<a href=\"index.php\">Home</a> | <a href=\"sign.php\">Sign</a> <a href=\"view.php\">View Entries</a> | Other, Welcome! Edit all this text in the admin CP. This is NOT where you stick the form, etc., This is optional PHP, you don't really need it for the other page. But it is other, so add whatever you want here., This is where you put any other stuff, you can edit all of this in the admin CP., Footer BBZ. Add your copyright etc. here.);");

echo ("Step 1 done! Now, please enter your desired username and password for admin CP.<br />

<form action=\"?step=2" method=\"post\">
Username:<br />
<input type=\"text" name=\"name\"><br />
Password:<br />
<input type=\"text" name=\"password\\"><br />
<input type=\"submit" name=\"start" value=\"Step 2\"></form>");
};

$user = ($_POST["username"]);
$pass = ($_POST["password"]);
$pass = md5($password);

elseif ($_GET['step'] == '2') {
$query = mysql_query("INSERT INTO `users` ( `uid` , `username` , `password` ) VALUES ( NULL, ‘$user’, ‘$pass‘ )");
};

else ("Welcome to the erPETITION v0.1 installer! This will add all the necessary databases and codes into your mySQL DB. Before you continue, <strong>please</strong> make sure your database info is correct.
Host: $db[host] <br>Username: $db[user] <br>Password: $db[pass] <br> Database: $db[name]<br />
If your database info is incorrect, please go and edit config.php now.<br />
<form action=\"?step=1" method=\"post\"><input type=\"submit" name=\"start" value=\"Step 1\"></form>");

?>

Current error: The last line (php closing ?>).

adamFTW
15-12-2007, 01:17 PM
After you closed it, there was still some more PHP code left..?

rh4u
15-12-2007, 02:20 PM
<?
##WERE GOING TO CONFIGURE SOME VARIABLES !

$installerpagename = "installer.php"; #CHANGE THIS TO THE NAME OF THE INSTALLER PAGE
include "iconfig.php";

// DO NOT edit the following unless you know what you are doing
if ($_GET['step'] == '1') {
$query = mysql_query("CREATE TABLE `users` (
`uid` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(50) NOT NULL,
`password` varchar(500) NOT NULL,
PRIMARY KEY (`uid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;");

$query = mysql_query("CREATE TABLE `petition` (
`id` INT( 20 ) NOT NULL AUTO_INCREMENT ,
`name` VARCHAR( 30 ) NOT NULL ,
`other` VARCHAR( 30 ) NOT NULL ,
`comment` VARCHAR( 200 ) NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM");

$query = mysql_query("CREATE TABLE `admin` (
`navigation` TEXT( 10000 ) NOT NULL ,
`maincontent` TEXT( 10000 ) NOT NULL ,
`php` TEXT( 10000 ) NOT NULL ,
`other` TEXT( 10000 ) NOT NULL ,
`footer` VARCHAR( 10000 ) NOT NULL
) ENGINE = MYISAM");

$query = mysql_query("CREATE TABLE `home` (
`navigation` TEXT( 10000 ) NOT NULL ,
`maincontent` TEXT( 10000 ) NOT NULL ,
`php` TEXT( 10000 ) NOT NULL ,
`other` TEXT( 10000 ) NOT NULL ,
`footer` TEXT( 10000 ) NOT NULL
) ENGINE = MYISAM");

$query = mysql_query("CREATE TABLE `other` (
`navigation` TEXT( 10000 ) NOT NULL ,
`maincontent` TEXT( 10000 ) NOT NULL ,
`php` TEXT( 10000 ) NOT NULL ,
`other` TEXT( 10000 ) NOT NULL ,
`footer` TEXT( 10000 ) NOT NULL
) ENGINE = MYISAM");

$query = mysql_query("CREATE TABLE `sign` (
`navigation` TEXT( 10000 ) NOT NULL ,
`maincontent` TEXT( 10000 ) NOT NULL ,
`php` TEXT( 10000 ) NOT NULL ,
`other` TEXT( 10000 ) NOT NULL ,
`footer` TEXT( 10000 ) NOT NULL
) ENGINE = MYISAM");

$query = mysql_query("CREATE TABLE `view` (
`navigation` TEXT( 10000 ) NOT NULL ,
`maincontent` TEXT( 10000 ) NOT NULL ,
`php` TEXT( 10000 ) NOT NULL ,
`other` TEXT( 10000 ) NOT NULL ,
`footer` TEXT( 10000 ) NOT NULL
) ENGINE = MYISAM");

$query = mysql_query("CREATE TABLE `titles` (
`home` TEXT( 10000 ) NOT NULL ,
`sign` TEXT( 10000 ) NOT NULL ,
`view` TEXT( 10000 ) NOT NULL ,
`other` TEXT( 10000 ) NOT NULL
) ENGINE = MYISAM");

$query = mysql_query("INSERT INTO `admin` (`navigation`, `maincontent`, `php`, `other`, `footer`) VALUES (Home | <a href=\"edit.php\">View + Edit Comments / Other Details</a> | <a href=\"editpage.php\">Edit Pages</a> | <a href=\"editsite.php\">Edit Site Details</a>, Welcome to the administration panel, use the links above to navigate your way through the panel., This is optional PHP, you don't really need it for the admin CP main page., This is where you put any other stuff, you can edit all of this using the Edit Site Pages link., Footer BBZ. Add your copyright etc. here.);");

$query = mysql_query("INSERT INTO `home` (`navigation`, `maincontent`, `php`, `other`, `footer`) VALUES (Home | <a href=\"sign.php\">Sign</a> <a href=\"view.php\">View Entries</a> | <a href=\"other.php\">Other</a>, Welcome! Edit all this text in the admin CP., This is optional PHP, you don't really need it for the main page., This is where you put any other stuff, you can edit all of this using the Edit Site Pages link., Footer BBZ. Add your copyright etc. here.);");

$query = mysql_query("INSERT INTO `sign` (`navigation`, `maincontent`, `php`, `other`, `footer`) VALUES (<a href=\"index.php\">Home</a> | Sign <a href=\"view.php\">View Entries</a> | <a href=\"other.php\">Other</a>, Welcome! Edit all this text in the admin CP. This is NOT where you stick the form, etc.");
// The database
include 'config.php';

// The variables
$name = $_POST["name"];
$other = $_POST["other"];
$comment = $_POST["comment"];
$ip = $_SERVER[REMOTE_ADDR];

//Those horrible IF's - Form data
if ($_GET["action"] == "submit")
{
if ($name == "")
{
echo "Whoops! You didn't enter your name.";
exit;
}


if ($comment== "")
{
echo "Whoops! You didnt enter a comment.";
exit;
}
$name = addslashes(htmlspecialchars($name));
$grade = addslashes(htmlspecialchars($grade));
$comment = addslashes(htmlspecialchars($comment));
$addpetition = mysql_query("INSERT INTO `petition` (`name`, `other`, `comment`, `ip`) VALUES ('$name','$other','$comment', '$ip')");

// The form details are fine, display text & details
echo "Thank you for signing the petition! Here are the details you submitted: <br />
Name: $name<br />
Other: $other<br />
Your comment: $comment<br />
<br />
To view all the signatures, click <a href=\"view.php\">here.</a> To go back to the home page, click <a href=\"index.php\">here.</a>";
exit;
}

else
// Display the form
{
echo "
<div align=\"center\">Want Miss Oppedisano to stay at O.L.H? Sign the petition below. Your support is needed.<br />
<strong>Remember, only sign the petition once!</strong></div><br />
<br />
<form action=\"?action=submit\" method=\"post\">
<div id=\"title\">Name:</div>
<input type=\"text\" name=\"name\"><br /><br />
<div id=\"title\">Other (EDIT IN ADMIN CP):</div>
<input type=\"text\" name=\"other\"><br /><br />
<div id=\"title\">Comment:</div>
<style=\"width=\"169\"; height=\"116\"><textarea rows=\"7\" input type=\"text\" name=\"comment\" cols=\"28\"></textarea><br />
<input type=\"submit\" name=\"submit\" value=\"Sign the petition!\">
</form>";
exit;
}
##This is where you put any other stuff, you can edit all of this using the
##Edit Site Pages link., Footer BBZ. Add your copyright etc. here.);");
exit;
}

$query = mysql_query("INSERT INTO `view` (`navigation`, `maincontent`, `php`, `other`, `footer`) VALUES (<a href=\"index.php\">Home</a> | <a href=\"sign.php\">Sign</a> View Entries | <a href=\"other.php\">Other</a>, Welcome! Edit all this text in the admin CP. This is NOT where you stick the form, etc., <?php
//DB connection
include "config.php";

// Display number of entries
$query = mysql_query("select count(*) from petition");
$result = mysql_result($query, 0);
echo "We have a total of <strong>$result</strong> signatures!";
// The database connetcion
include "config.php";

$sql = "SELECT * FROM petition";
$check = mysql_query("SELECT name, other, comment FROM petition") or die("Sorry, the data couldn't be displayed. Please check back later.");
// The above variables will be used to check our connection to MySQL.

while ($display = mysql_fetch_array($check)) {

$name = $display['name'];
$other = $display['other'];
$comment = $display['comment'];

// Above are variables defined for our Name, Gradeand Comment.

echo "
<strong>Name:</strong> $name
<br>
<strong>Other:</strong> $other
<br>
<strong>Comment:</strong><br>$comment
<br>
__________________________________________________ __________<br /><br />
";

}
##This is where you put any other stuff, you can edit all of this using the
##Edit Site Pages link., Footer BBZ. Add your copyright etc. here.);");

$query = mysql_query("INSERT INTO `other` (`navigation`, `maincontent`, `php`, `other`, `footer`) VALUES (<a href=\"index.php\">Home</a> | <a href=\"sign.php\">Sign</a> <a href=\"view.php\">View Entries</a> | Other, Welcome! Edit all this text in the admin CP. This is NOT where you stick the form, etc., This is optional PHP, you don't really need it for the other page. But it is other, so add whatever you want here., This is where you put any other stuff, you can edit all of this in the admin CP., Footer BBZ. Add your copyright etc. here.);");

print ("
Step 1 Complete! Please Enter your AdminCP Details:\n \n \n \n \n \n
<form action=\"$installerpagename?step=2\" method=\"post\">
Username:
<input type=\"text\" name=\"name\">\n
Password:
<input type=\"text\" name=\"password\"><br />
<input type=\"submit\" name=\"start\" value=\"Step 2\"></form>");
};

$user = ($_POST["username"]);
$pass = ($_POST["password"]);
$pass = md5($password);

elseif ($_GET['step'] == '2') {
$query = mysql_query("INSERT INTO `users` ( `uid` , `username` , `password` ) VALUES ( NULL, ‘$user’, ‘$pass‘ )");
};

else ("Welcome to the erPETITION v0.1 installer! This will add all the necessary databases and codes into your mySQL DB. Before you continue, <strong>please</strong> make sure your database info is correct.
Host: $db[host] <br>Username: $db[user] <br>Password: $db[pass] <br> Database: $db[name]<br />
If your database info is incorrect, please go and edit config.php now.<br />
<form action=\"?step=1" method=\"post\"><input type=\"submit" name=\"start" value=\"Step 1\"></form>");

?>
Try that :)

RYANNNNN
15-12-2007, 03:39 PM
What's the point in doing $query = mysql_query... etc?

I'm pretty sure that wont actually execute, just take out $query =

Hitman
15-12-2007, 03:58 PM
What's the point in doing $query = mysql_query... etc?

I'm pretty sure that wont actually execute, just take out $query =It does execute, I do it - but it isn't needed, I don't think.

Beau
15-12-2007, 08:16 PM
It executes, because it's determining the value of the $query value, which is what you're technically telling the script to do.

Want to hide these adverts? Register an account for free!