PDA

View Full Version : Setting up MySql Databases.



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

lordsaturn
12-15-2008, 07:13 AM
Very picture-heavy, very noob-proof.

GJ :)

Kyle Undefined
12-15-2008, 07:43 AM
Very picture-heavy, very noob-proof.

GJ :)

Thanks, that's what I was going for.

~Camo

TViYH
12-15-2008, 09:46 PM
Mmmm. I actually understand this.

Thanks!

+rep.

EDIT: WATE! WARE IS DB.TEXT?!

NiCbaZ
12-17-2008, 11:13 PM
Mmmm. I actually understand this.

Thanks!

+rep.

EDIT: WATE! WARE IS DB.TEXT?!

Agreed im stuck there as well . you didnt attach it ?

P1nky
12-18-2008, 12:04 AM
gj, btw i know that website and stuff , though i was a nooby back than.

TViYH
12-18-2008, 12:56 AM
Camo_Kyle!

Ware is DB.TXT?!

Kyle Undefined
12-18-2008, 02:57 AM
Oops lol. I'll attach it...Sorry. :/ I'm surprised nobody has asked for this account. It's fully setup and just sitting there...

~Camo

Sandstorm
12-18-2008, 03:25 AM
I'll take it actually. Would be useful for checking up while I'm at school :).

Kyle Undefined
12-18-2008, 03:40 AM
Ok, I'll send you the stuff in a little bit. Still eating mah wrap...

~Camo

TViYH
12-18-2008, 04:00 AM
:(

It didn't has worked :(

It added it to the db, but show.php didn't view it.

:(

Kyle Undefined
12-18-2008, 04:11 AM
How are you calling the function? Maybe you're calling it wrong.

~Camo

NiCbaZ
12-18-2008, 08:39 AM
Ok i setup one, how do i setup so theres a seperate page for each script?

Ive tryed this.

PostReport('RangeGuilder!', 'http://www.nicbaz.site90.net/add.php?name=mage', GetDebugText);

but that shows up all the old ones as well?

Also some help if over writing cause this is useless if it just keeps on repeat the proggie onto the page.

Thanks very much for all the help so far :)

TViYH
12-18-2008, 12:12 PM
Camooooooo, I called it just how you showed it in your script, except I called it to my website.

Sandstorm
12-18-2008, 01:20 PM
Did you add the Http://www. to both the site your trying to view, and the one your trying to load to? If not, that's why. I got pissed about that yesterday xD.

Kyle Undefined
12-18-2008, 03:08 PM
Ok i setup one, how do i setup so theres a seperate page for each script?

Ive tryed this.

PostReport('RangeGuilder!', 'http://www.nicbaz.site90.net/add.php?name=mage', GetDebugText);

but that shows up all the old ones as well?

Also some help if over writing cause this is useless if it just keeps on repeat the proggie onto the page.

Thanks very much for all the help so far :)

It would be like this:
Postreport('Script Name', 'http://www.nicbaz.site90.net/add.php', GetDebugText);

~Camo

NiCbaZ
12-18-2008, 08:02 PM
That wont make a unique page for each user tho will it


Postreport('Script Name', 'http://www.nicbaz.site90.net/add.php', GetDebugText);


im dtrying to do what you did here...


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

Kyle Undefined
12-19-2008, 04:39 AM
I haven't fully built that yet sorry. I was just adding it so when I do :/

~Camo

tls
01-28-2009, 05:53 AM
This might be a gravedig, but I just actually made one of these. So you can clear your database of my stuff Camo!

Kyle Undefined
01-29-2009, 12:34 AM
K, doing that now ;) Thanks for using my procedure!

~Camo

Magiic
01-29-2009, 08:59 PM
erm, so whenever i attempt to access the site +/show.php i get an access denied error

tls
02-09-2009, 04:42 AM
How do I clear my database...?

XRaye
03-27-2009, 09:43 PM
Omgzor it works :D Thanks!!

But yeah how do you clear the stuff in mysite.com/show.php?

TRiLeZ
04-06-2009, 10:39 PM
What is the function for the script to post the proggy?
I tryed PostReport but there is no such function. Do I need to download the function and put it in my script?

EDIT:Never mind, I found Camo's function

EvilChicken!
10-31-2009, 01:45 PM
Might wanna remove the part begging for reputation.

Otherwise, it's an all okay tutorial.