Kyle Undefined
12-15-2008, 06:46 AM
K, well this a tutorial due to request by EvilChicken! Also, it can be used to go along with Floor66 and my function found Here (http://www.villavu.com/forum/showthread.php?t=39589) So lets begin shall we? But first, I'm going to give away this setup to the first active and useful person, I already have one and I don't need another.
First of all, you will need a MySql database with PHP. If you don't have one you can get one from here.
http://img.photobucket.com/albums/v489/LilDukey/WebHost.jpg
After you get there you will see the home page, Find the Sign Up! button to the bottom right.
http://img.photobucket.com/albums/v489/LilDukey/SignUP-1-1.jpg
Fill out the form accordingly and hit submit
http://img.photobucket.com/albums/v489/LilDukey/Account.jpg
You will be brought to a Account Overview page. Click on Enter Control Panel. You will be brought to a page that looks like this.
http://img.photobucket.com/albums/v489/LilDukey/CPanel.jpg
K now, to begin lets start off by setting the files up. I can't upload them so I have to paste them. Name them exactly as I do. (Copy and paste into Notepad or whatever you use and save the name as I have)
1) cfg.php
<?php
$Mysql_Host = "HOST";
$Mysql_User = "USER";
$Mysql_Pass = "PASS";
$Mysql_DB = "DB";
$con = mysql_connect($Mysql_Host, $Mysql_User, $Mysql_Pass);
if (!$con)
{
die(mysql_error());
} else {
if (!mysql_select_db($Mysql_DB))
{
die(mysql_error());
}
}
?>
2) add.php
<?php
include "cfg.php";
if (isset($_POST['proggy']))
{
$Prog = $_POST['proggy'];
if (empty($Prog))
{
echo "Error";
} else {
$sql = mysql_query("INSERT INTO `proggies` (Proggy) VALUES ('$Prog')");
if (!$sql)
{
die(mysql_error());
}
exit;
}
}
?>
<form method="post" action="<?=$_SERVER['PHP_SELF'];?>">
<input type="hidden" name="proggy" value="N/A" />
</form>
3) show.php
<?php
include "cfg.php";
$p = $_GET['page'];
if (empty($p) || $p == '')
{
$p = 1;
} else {
$p = $_GET['page'];
}
$limit = $_GET['max'];
if (empty($limit) || $limit == '')
{
$limit = 5;
} else {
$limit = $_GET['max'];
}
$start_from = ($p-1) * $limit;
$result = mysql_query("SELECT * FROM `proggies` LIMIT ". $start_from .",". $limit);
$total = mysql_query("SELECT count(*) FROM `proggies`");
$total = mysql_result($total, 0);
if ($p > ceil($total/$limit))
{
echo "<strong>Incorrect pageID</strong><br />";
echo "<a href='?page=1&max=". $limit ."'>Back to page 1</a>";
exit;
}
echo "Page(s): || ";
$i = 1;
while ($i <= (ceil($total/$limit)))
{
if ($p == $i)
{
echo "<strong>". $i ."</strong> || ";
} else {
echo "<a href='?page=". $i ."&max=". $limit ."'>". $i ."</a> || ";
}
$i++;
}
echo "<br /><br />";
while($row = mysql_fetch_array($result))
{
echo "<strong>". $row['scn'] ."</strong>";
echo "<PRE>". stripslashes($row['Proggy']) ."</PRE>";
}
?>
Now after you have done that, go back to the Control Panel (C-Panel) on the site and find the File Manager button near the middle of the page and click it. You may have to sign in again. (Your pass is what you used to signup with)
http://img.photobucket.com/albums/v489/LilDukey/FileMan-1.jpg
You will be brought to a page that looks like this. Click on public_html.
http://img.photobucket.com/albums/v489/LilDukey/FTP.jpg
Now click on upload and you will be brought to a upload page. Upload all three files. Click on the green check mark.
http://img.photobucket.com/albums/v489/LilDukey/Upload.jpg
Make sure you see this conformation and hit the blue arrow to go back.
http://img.photobucket.com/albums/v489/LilDukey/Uploaded.jpg
Now, delete the default.php file. It is necessary, especially if you want to make your site look a little better. Later we will setup the cfg.php but have to setup the database now. Click on the MySQL button to setup the database.
http://img.photobucket.com/albums/v489/LilDukey/Mysql.jpg
Fill in the Create new database form and click Create Database. (You can use any name you want.)
http://img.photobucket.com/albums/v489/LilDukey/Db.jpg
You will see a screen that has information that you're going to need. So write that down and go back to the File Manager and go back to cfg.php and click edit to the right.
http://img.photobucket.com/albums/v489/LilDukey/Info-1.jpg
Edit cfg.php with what you got from the step above so it looks like this. Hit the blue save button then the blue arrow after it saves. You can exit this after.
http://img.photobucket.com/albums/v489/LilDukey/Cfg.jpg
Now go back to the C-Panel and click on the phpMyAdmin button.
http://img.photobucket.com/albums/v489/LilDukey/Php.jpg
Under the List of Databases click on EnterphpMyAdmin and you will be brought to this page.
http://img.photobucket.com/albums/v489/LilDukey/phpmyadmin.jpg
Click on Import in the upper right of the screen.
http://img.photobucket.com/albums/v489/LilDukey/Import.jpg
A upload form will be the next thing you see. But first, download the DB.txt that I have attached to this tut. Now click on browse and locate and click on the DB file. Click on Go at the bottom. To the left you will see "proggies" under your database name. Click it. Now for a little editing. Click on the green pencil.
http://img.photobucket.com/albums/v489/LilDukey/proggies.jpg
Click on the Collation drop down menu. Scroll down to the very bottom. Select the utf8_unicode_ci. Then hit save.
http://img.photobucket.com/albums/v489/LilDukey/Collation.jpg
Now you don't have to but I like setting everything up for unicode. If you want you can click on your database name to the left. Click on Operations near the top right. Find the Collation section near the bottom and on the drop down menu use the unicode specified above located at the very bottom. Click on Go to save it. Now, click on "proggies" on the left and click on Operations also. Do the same for the collation. If you don't do that then click on "proggies" and add another field to the database. Click on Go since everything is setup already.
http://img.photobucket.com/albums/v489/LilDukey/Field.jpg
Now just set it up like the following. Hit Save.
http://img.photobucket.com/albums/v489/LilDukey/Field2.jpg
You're probably wondering what that does. It allows you to search for proggies by name on your site. So you can filter like this sitename.com/add.php?name=whatever
So you're all set up and ready to use this database for the function or whatever else you need. But right now all your public_html files are viewable and looks nasty. Lets make your site at least look better. Find and click the Website Builder button which is in the same line as the phpMyAdmin and MySQL.
http://img.photobucket.com/albums/v489/LilDukey/WB.jpg
Click on the first step and just follow the instructions for setting up the design you want.
And there you have it. Your own MySQL Database with PHP! This can be very useful with the function. Like I said at the beginning. I'm giving this away to the first active and useful person. Hope you enjoyed the tut! Please post anything that you feel needed to be added/explained or whatever.
Thanks for reading!
~Camo
First of all, you will need a MySql database with PHP. If you don't have one you can get one from here.
http://img.photobucket.com/albums/v489/LilDukey/WebHost.jpg
After you get there you will see the home page, Find the Sign Up! button to the bottom right.
http://img.photobucket.com/albums/v489/LilDukey/SignUP-1-1.jpg
Fill out the form accordingly and hit submit
http://img.photobucket.com/albums/v489/LilDukey/Account.jpg
You will be brought to a Account Overview page. Click on Enter Control Panel. You will be brought to a page that looks like this.
http://img.photobucket.com/albums/v489/LilDukey/CPanel.jpg
K now, to begin lets start off by setting the files up. I can't upload them so I have to paste them. Name them exactly as I do. (Copy and paste into Notepad or whatever you use and save the name as I have)
1) cfg.php
<?php
$Mysql_Host = "HOST";
$Mysql_User = "USER";
$Mysql_Pass = "PASS";
$Mysql_DB = "DB";
$con = mysql_connect($Mysql_Host, $Mysql_User, $Mysql_Pass);
if (!$con)
{
die(mysql_error());
} else {
if (!mysql_select_db($Mysql_DB))
{
die(mysql_error());
}
}
?>
2) add.php
<?php
include "cfg.php";
if (isset($_POST['proggy']))
{
$Prog = $_POST['proggy'];
if (empty($Prog))
{
echo "Error";
} else {
$sql = mysql_query("INSERT INTO `proggies` (Proggy) VALUES ('$Prog')");
if (!$sql)
{
die(mysql_error());
}
exit;
}
}
?>
<form method="post" action="<?=$_SERVER['PHP_SELF'];?>">
<input type="hidden" name="proggy" value="N/A" />
</form>
3) show.php
<?php
include "cfg.php";
$p = $_GET['page'];
if (empty($p) || $p == '')
{
$p = 1;
} else {
$p = $_GET['page'];
}
$limit = $_GET['max'];
if (empty($limit) || $limit == '')
{
$limit = 5;
} else {
$limit = $_GET['max'];
}
$start_from = ($p-1) * $limit;
$result = mysql_query("SELECT * FROM `proggies` LIMIT ". $start_from .",". $limit);
$total = mysql_query("SELECT count(*) FROM `proggies`");
$total = mysql_result($total, 0);
if ($p > ceil($total/$limit))
{
echo "<strong>Incorrect pageID</strong><br />";
echo "<a href='?page=1&max=". $limit ."'>Back to page 1</a>";
exit;
}
echo "Page(s): || ";
$i = 1;
while ($i <= (ceil($total/$limit)))
{
if ($p == $i)
{
echo "<strong>". $i ."</strong> || ";
} else {
echo "<a href='?page=". $i ."&max=". $limit ."'>". $i ."</a> || ";
}
$i++;
}
echo "<br /><br />";
while($row = mysql_fetch_array($result))
{
echo "<strong>". $row['scn'] ."</strong>";
echo "<PRE>". stripslashes($row['Proggy']) ."</PRE>";
}
?>
Now after you have done that, go back to the Control Panel (C-Panel) on the site and find the File Manager button near the middle of the page and click it. You may have to sign in again. (Your pass is what you used to signup with)
http://img.photobucket.com/albums/v489/LilDukey/FileMan-1.jpg
You will be brought to a page that looks like this. Click on public_html.
http://img.photobucket.com/albums/v489/LilDukey/FTP.jpg
Now click on upload and you will be brought to a upload page. Upload all three files. Click on the green check mark.
http://img.photobucket.com/albums/v489/LilDukey/Upload.jpg
Make sure you see this conformation and hit the blue arrow to go back.
http://img.photobucket.com/albums/v489/LilDukey/Uploaded.jpg
Now, delete the default.php file. It is necessary, especially if you want to make your site look a little better. Later we will setup the cfg.php but have to setup the database now. Click on the MySQL button to setup the database.
http://img.photobucket.com/albums/v489/LilDukey/Mysql.jpg
Fill in the Create new database form and click Create Database. (You can use any name you want.)
http://img.photobucket.com/albums/v489/LilDukey/Db.jpg
You will see a screen that has information that you're going to need. So write that down and go back to the File Manager and go back to cfg.php and click edit to the right.
http://img.photobucket.com/albums/v489/LilDukey/Info-1.jpg
Edit cfg.php with what you got from the step above so it looks like this. Hit the blue save button then the blue arrow after it saves. You can exit this after.
http://img.photobucket.com/albums/v489/LilDukey/Cfg.jpg
Now go back to the C-Panel and click on the phpMyAdmin button.
http://img.photobucket.com/albums/v489/LilDukey/Php.jpg
Under the List of Databases click on EnterphpMyAdmin and you will be brought to this page.
http://img.photobucket.com/albums/v489/LilDukey/phpmyadmin.jpg
Click on Import in the upper right of the screen.
http://img.photobucket.com/albums/v489/LilDukey/Import.jpg
A upload form will be the next thing you see. But first, download the DB.txt that I have attached to this tut. Now click on browse and locate and click on the DB file. Click on Go at the bottom. To the left you will see "proggies" under your database name. Click it. Now for a little editing. Click on the green pencil.
http://img.photobucket.com/albums/v489/LilDukey/proggies.jpg
Click on the Collation drop down menu. Scroll down to the very bottom. Select the utf8_unicode_ci. Then hit save.
http://img.photobucket.com/albums/v489/LilDukey/Collation.jpg
Now you don't have to but I like setting everything up for unicode. If you want you can click on your database name to the left. Click on Operations near the top right. Find the Collation section near the bottom and on the drop down menu use the unicode specified above located at the very bottom. Click on Go to save it. Now, click on "proggies" on the left and click on Operations also. Do the same for the collation. If you don't do that then click on "proggies" and add another field to the database. Click on Go since everything is setup already.
http://img.photobucket.com/albums/v489/LilDukey/Field.jpg
Now just set it up like the following. Hit Save.
http://img.photobucket.com/albums/v489/LilDukey/Field2.jpg
You're probably wondering what that does. It allows you to search for proggies by name on your site. So you can filter like this sitename.com/add.php?name=whatever
So you're all set up and ready to use this database for the function or whatever else you need. But right now all your public_html files are viewable and looks nasty. Lets make your site at least look better. Find and click the Website Builder button which is in the same line as the phpMyAdmin and MySQL.
http://img.photobucket.com/albums/v489/LilDukey/WB.jpg
Click on the first step and just follow the instructions for setting up the design you want.
And there you have it. Your own MySQL Database with PHP! This can be very useful with the function. Like I said at the beginning. I'm giving this away to the first active and useful person. Hope you enjoyed the tut! Please post anything that you feel needed to be added/explained or whatever.
Thanks for reading!
~Camo