Go Back   I-Mockery Forum > I-Mockery Miscellaneous Forums > Questions, Suggestions, and Tech Support
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
  #1  
Chojin Chojin is offline
was never good
Chojin's Avatar
Join Date: Apr 1999
Chojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contest
Old Dec 28th, 2006, 08:56 PM        HEPS ME with MySQL and stuff prz
Okay so I have this site: http://www.erickandemily.com

How would I go about making a real live database to store the reviews and automatically generate tables like the one on the front page?

Also, I'm currently hosted with 100megswebhosting, but I found this other group, bluehost.com. Their offer is:

200 GB Storage
2,000 GB Bandwidth/mo
50 MySQL databases

Among other things, for something stupid like $7.95/mo, but you have to pay a year in advance. Their website looks a little sketchy though, and having to pay for a year up front screams 'scam' at me. The whole thing sounds a little too good to be true, as my current host is comparatively cheap and is charging me $40/mo for 240GB bandwidth.

Looking at archive.org, the site was founded in 2000 as some crazy dotcom virtual office bullshit, then stolens away in 2003 by its current owner, who's been doing web hosting since then.

What do you guys think? And please answer both questions: HOW MYSQL DATABASE DURR and BLUEHOST SCAM?
Reply With Quote
  #2  
kahljorn kahljorn is offline
BANNED
 
Join Date: May 2000
Location: NO
kahljorn won the popularity contestkahljorn won the popularity contestkahljorn won the popularity contestkahljorn won the popularity contestkahljorn won the popularity contestkahljorn won the popularity contestkahljorn won the popularity contestkahljorn won the popularity contestkahljorn won the popularity contestkahljorn won the popularity contestkahljorn won the popularity contest
Old Dec 28th, 2006, 11:42 PM       
:throwshepatitisfecesinyourface!
__________________
NEVER
Reply With Quote
  #3  
Chojin Chojin is offline
was never good
Chojin's Avatar
Join Date: Apr 1999
Chojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contest
Old Dec 29th, 2006, 10:03 PM       
HEPS ME METULMILISHA
Reply With Quote
  #4  
MetalMilitia MetalMilitia is offline
Hitler's Canoe!
MetalMilitia's Avatar
Join Date: Sep 2004
Location: UK
MetalMilitia is probably a spambot
Old Dec 30th, 2006, 12:30 PM       
Assuming the server supports PHP you should be able to access something like 'phpmyadmin' which allows you to create and edit a database and the tables within your database.

Once you have the database set up it's suprisingly simple to grab data out of the database and format it however you want.

Here is a page I made some time ago while I was learning how to do it:

The following code is for the main news page

Code:
<link rel="stylesheet" type="text/css" href="style_main.css" media="all" />

<html>
	<body class="section-1">
		<?php
			include 'head.php';

			include 'tabMenu.php';

			include 'newsContent.php';
   		?>
	</body>

</html>
As you can see it's basically just the head with whatever crap you want in there, then the code for the menu and finally the code for adding news to the page.

The 'newsContent.php' file contains all the code to perform the following actions:

1. Set up the database connection string
2. Select the database we wish to access
3. Create a query
4. Perform the query
5. Copy the results into an array
6. Format and output whatever parts of the array we want to use


1. Set up the database connection string

Code:
$dbcnx = mysql_connect("servername e.g. localhost", "username","password");								//set up our connection string

//Do some validation here to check the connection succeeded
2. Select the database (inc. validation)


Code:
	
if (! @mysql_select_db("databasename", $dbcnx) )	//select a database, if we cannot find it generate an error. note: @ disables php errors and lets us use our own
{
	echo( "

Unable to locate the tablename database at this time.</p>" );
	exit();
}
3. Create the query

Code:
$query=" SELECT * FROM news ORDER BY dateSub DESC ";
This would select all items from the news table and order then by the datesubmitted field (DESC reverses the resutls so you get the newest items at the top)

4. Perform the query

Code:
$result=mysql_query($query);
This will just pull all selected data out of the database and put it in the variable; "result".

5. Copy the results into an array & 6. Format and output whatever parts of the array we want to use

Code:
while($thenews = mysql_fetch_array($result))
{
	echo " <div class='newsitem'> ";
	echo "<div class='header'> $thenews[title] </div>";
	echo "

 $thenews[synop] </p>";
	echo "

Posted by $thenews[authName] at $thenews[dateSub] </p>";
	echo "</div>";
}
Here loop through all of our results (a while loop will keep going while a certain critera is true, in this case the critera is that we still have results to be processed. Once where are no more records to output the loop will finish) copying the data into another variable; 'thenews'.
We then output the contents of this variable with formatting information. In this example the CSS class 'newsitem' contains code to put a box around all the content so each news item appears to be a seperate object.
The next interesting part is where you create a link to the whole article in the title of the news item (assuming that's how you want the site to work). In the link it is important that we insert the article's ID so when we click the link we can have some simple PHP code to read the info from the URL, query the database for the article with a corrisponding ID and display this article in a new page.

The way I have set up my table is to have a synopsis field which the article's author writes when they submit the article. You could have some clever code which extracts, say, 100 words from the article's main content and displays that but I couldn't be arsed when I wrote this.

Here is what it looks like when it's opened in a browser:




Now you need the following things:

1. Code to limit the number of articles per page/create new pages when the number of articles increases

2. A login system (for content contributors to use)

3. A webform which allows you to insert data to the database


I'm really new to PHP (I've only ever made this one site and never finished it as I had too much else on) so take all this info with a grain of salt. This may not be the best way of doing it but it seems to work well.


Oh, and I don't know about the web hosting company. I think there are probably web host review sites floating around the net. Check those out.
__________________
Quote:
Originally Posted by bigtimecow View Post
japan
Reply With Quote
  #5  
whoreable whoreable is offline
Mocker
whoreable's Avatar
Join Date: Feb 2003
whoreable is probably a spambot
Old Dec 31st, 2006, 11:50 PM       
i have had bluehost like a year now, its pretty ok. they do have phpmyadmin

and you could code that shit like metal milita showed, or just look for an already made script to change from sourceforge.
__________________
may the wings of liberty never loose a feather!
Reply With Quote
  #6  
sadie sadie is offline
ineffable
 
Join Date: Jul 2002
Location: ineffability
sadie is probably a spambot
Old Jan 1st, 2007, 11:56 PM       
i don't know crap about this stuff, but hello to whoreable!
Reply With Quote
  #7  
FartinMowler FartinMowler is offline
Banned
FartinMowler's Avatar
Join Date: Feb 2003
Location: incoherant
FartinMowler sucks
Old Jan 1st, 2007, 11:59 PM       
I'm completely shitfaced
Reply With Quote
  #8  
Chojin Chojin is offline
was never good
Chojin's Avatar
Join Date: Apr 1999
Chojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contest
Old Jan 6th, 2007, 02:24 PM       
Thanks metal, I'll look into that when i have more time.

Whoreable, how does their speed compare with other hosters? Do they monitor content at all? Could I just host a shitfuckton of videos there and link remotely to them?
Reply With Quote
  #9  
Chojin Chojin is offline
was never good
Chojin's Avatar
Join Date: Apr 1999
Chojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contest
Old Jan 17th, 2007, 06:01 PM       
Metal, how do I set up the database's values for "authname", "datesub", etc.?

As in, how do I add those categories and then put entries under them?
Reply With Quote
  #10  
MetalMilitia MetalMilitia is offline
Hitler's Canoe!
MetalMilitia's Avatar
Join Date: Sep 2004
Location: UK
MetalMilitia is probably a spambot
Old Jan 17th, 2007, 07:25 PM       
You need to open PHPMyAdmin ('servername/phpmyadmin' should work if it's installed). It should look like this:



Then you can just put a database name into one of the places I circled and click create.

You'll then see this screen:



Where you can add a table with however many fields (columns) you want.

The rest is pretty self explanitory.

Phpmyadmin takes a bit of getting used to but you should be able to pick it up quickly.

If it's not installed on your server you should have something similar which will do the same thing.
__________________
Quote:
Originally Posted by bigtimecow View Post
japan
Reply With Quote
  #11  
Chojin Chojin is offline
was never good
Chojin's Avatar
Join Date: Apr 1999
Chojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contest
Old Jan 18th, 2007, 12:04 PM       
Yeah, I've got cpanel, so I'll try that when I get home today.

Also, is it possible to do a php include on a txt file, but only have it return a certain number of characters instead of the whole document?
Reply With Quote
  #12  
MetalMilitia MetalMilitia is offline
Hitler's Canoe!
MetalMilitia's Avatar
Join Date: Sep 2004
Location: UK
MetalMilitia is probably a spambot
Old Jan 18th, 2007, 07:48 PM       
Yeah should be.

Take a look at this: http://www.tizag.com/phpT/fileread.php
__________________
Quote:
Originally Posted by bigtimecow View Post
japan
Reply With Quote
  #13  
AChimp AChimp is offline
Resident Chimp
AChimp's Avatar
Join Date: Nov 2000
Location: The Jungles of Borneo
AChimp is probably a real personAChimp is probably a real person
Old Jan 18th, 2007, 11:36 PM       
You can do that, but file I/O on webservers can be dangerous.
Reply With Quote
  #14  
Chojin Chojin is offline
was never good
Chojin's Avatar
Join Date: Apr 1999
Chojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contest
Old Jan 20th, 2007, 04:06 PM       
Okay I'm starting to get a better hang of PHP and MySQL.

I now have a lil form that I made where I fill out information:



And it outputs to an archive file:



Most of these don't have 'description' information, so that's why that's missing. But the error there is from when I try to output the 'Favorite' information. On the input form, the favorite is defined like so:

Code:
<label for="favorite">Favorite Kitty?</label></td><td><input type="checkbox" value="favorite" name="favorite[]" id="favorite" />
and previous to that in the same file, (excerpted)

Code:
$favorite = htmlspecialchars(strip_tags($_POST['favorite']));
...
$sql = "INSERT INTO wiikitty_archive (timestamp,catname,location,catfilename,favorite,description) VALUES ('$timestamp','$catname','$location','$catfilename','$favorite','$description')";
and finally in the result file:

Code:
<?php foreach ($favorite as $f) {echo $f;} ?>
and that produces the above error. When I change that last bit of code to:

Code:
<?php echo $favorite; ?>
then I get this:



Where it just says 'Array' on the favorited WiiKitties. ("First submitted WiiKitty" is the description info)

So, how do I make it show the checkbox information?

Also, due to an oversight on my part, it wasn't adding the favorite information until that cat in the upper left. How would I go into the database manually to add that? Or to fix anything, really? I have phpMyadmin.
Reply With Quote
  #15  
FartinMowler FartinMowler is offline
Banned
FartinMowler's Avatar
Join Date: Feb 2003
Location: incoherant
FartinMowler sucks
Old Jan 20th, 2007, 04:30 PM       
I never got a thanks for promoting your Wiikitty site :/
Reply With Quote
  #16  
Chojin Chojin is offline
was never good
Chojin's Avatar
Join Date: Apr 1999
Chojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contest
Old Jan 20th, 2007, 04:46 PM       
i wasn't aware you did that.
Reply With Quote
  #17  
Chojin Chojin is offline
was never good
Chojin's Avatar
Join Date: Apr 1999
Chojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contest
Old Jan 20th, 2007, 04:54 PM       
also thanks to metal and chimp for helping me THUS FAR!
Reply With Quote
  #18  
Chojin Chojin is offline
was never good
Chojin's Avatar
Join Date: Apr 1999
Chojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contest
Old Jan 20th, 2007, 07:11 PM       
oaky a friend of mine helped me out already. at the top of the entry page I had to change it to:

Code:
if(isset($_POST['favorite'])) $favorite = 'y'; else $favorite = 'n';
and i had to take out the []s in the name variable so that it would no longer be an array.

Now, how do I password-protect a file or folder? I don't want other people to use my wiikitty submitter app.
Reply With Quote
  #19  
AChimp AChimp is offline
Resident Chimp
AChimp's Avatar
Join Date: Nov 2000
Location: The Jungles of Borneo
AChimp is probably a real personAChimp is probably a real person
Old Jan 21st, 2007, 10:20 AM       
I think that if you assign a value attribute to the checkbox, it will return that value rather than the name of the checkbox. Either way, just outputting the checkbox won't really display what you want.

Your friend is correct. You need to check for the checkbox value, then do something based on that value (or no value) with an if-statement.

Password protecting a folder can probably be done through your host. It's safest to do it at the server level rather than making a complicated login system. You should check out what kinds of things they offer in their control panel thing.
Reply With Quote
  #20  
Chojin Chojin is offline
was never good
Chojin's Avatar
Join Date: Apr 1999
Chojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contest
Old Jan 21st, 2007, 12:44 PM       
Cool! All right! Cool cool! All right!

I think I'm out of questions! Thanks, everybody!
Reply With Quote
  #21  
MetalMilitia MetalMilitia is offline
Hitler's Canoe!
MetalMilitia's Avatar
Join Date: Sep 2004
Location: UK
MetalMilitia is probably a spambot
Old Jan 22nd, 2007, 04:51 AM       
Quote:
Originally Posted by Chojin
also thanks to metal and chimp for helping me THUS FAR!
Anything to get more pictures of cats onto the Internet!
__________________
Quote:
Originally Posted by bigtimecow View Post
japan
Reply With Quote
  #22  
Chojin Chojin is offline
was never good
Chojin's Avatar
Join Date: Apr 1999
Chojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contestChojin won the popularity contest
Old Jan 22nd, 2007, 07:21 AM       
BTW you can see the fruits of these labors on http://www.wiikitty.com/wiikitties.php ;>
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

   


All times are GMT -4. The time now is 06:43 PM.


© 2008 I-Mockery.com
Powered by: vBulletin
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.