Earn Resources

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

gamer13
Forum Newbie
Posts: 9
Joined: Mon Jan 16, 2006 11:30 am

Earn Resources

Post by gamer13 »

Does any1 know a code (or make a code) that it has as function to get a specific amount of resources (metal or gold or wood) and let it go on for 24 hours a day?

And that you could buy something with it. But that you also could upgrade buildings so that the amount of resources increases?...


I don't know if it is possible, but I searched everywhere and found nothing.




Pleas help,

gaMer13
User avatar
phpdevuk
Forum Contributor
Posts: 220
Joined: Mon Jul 04, 2005 5:31 am
Location: UK
Contact:

Post by phpdevuk »

are you talking about some kind of game?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

I use simpletest browser class for that.. http://timvw.madoka.be/programming/php/smscity.php.txt.

But most online games require you to solve a captcha (find the letters in an image) before they acccept your commands...
gamer13
Forum Newbie
Posts: 9
Joined: Mon Jan 16, 2006 11:30 am

Post by gamer13 »

phpdevuk wrote:are you talking about some kind of game?
Yes for a game that I want to develop.

Look at the screeny from a game. (On the top of the screen you see "Metaal | Kristal | Deuterium etc" these are the resources that increase every 24 hours.)



@timvw : What do you mean with: captcha :?: I think you didn't understand my idea...
User avatar
phpdevuk
Forum Contributor
Posts: 220
Joined: Mon Jul 04, 2005 5:31 am
Location: UK
Contact:

Post by phpdevuk »

sounds like you are trying to build something along the lines of http://astronest.com, I've not heard fo any classes specifically for this sort of thing, but there may well be one out there, what places have you tried looking for them on?
gamer13
Forum Newbie
Posts: 9
Joined: Mon Jan 16, 2006 11:30 am

Post by gamer13 »

phpdevuk wrote:sounds like you are trying to build something along the lines of http://astronest.com, I've not heard fo any classes specifically for this sort of thing, but there may well be one out there, what places have you tried looking for them on?
1. HotScripts.com : For examples, but none are good enough
2. php.resourceindex.com : For examples, but none are good enough
3. Planet-Source-Code.com : For tutorials + examples, but found nothing
4. PHP.net : For snippets + tutorials, but found nothing
5. PHPHulp.nl : For tutorials + snippets, but found nothing

Well, I think thats already enough :D But I think those aren't all of them.

EDIT::
Btw thnx for the support. But I'm a little bit hopeless :P No, I haven't found anything yet
User avatar
phpdevuk
Forum Contributor
Posts: 220
Joined: Mon Jul 04, 2005 5:31 am
Location: UK
Contact:

Post by phpdevuk »

I guess you could always code it yourself using one of the others as a basis? incrementing a number in a database is as easy as recording a date really.
gamer13
Forum Newbie
Posts: 9
Joined: Mon Jan 16, 2006 11:30 am

Post by gamer13 »

phpdevuk wrote:I guess you could always code it yourself using one of the others as a basis? incrementing a number in a database is as easy as recording a date really.
I've studied PHP for 1 year but I think my title here on this forum "Beginner" is the correct term for me. I'm still studying PHP, but I don't know where to start because I don't have a basic think... :? :cry:

EDIT::
But I'll try
User avatar
phpdevuk
Forum Contributor
Posts: 220
Joined: Mon Jul 04, 2005 5:31 am
Location: UK
Contact:

Post by phpdevuk »

hehe I haven't got time to think too much about this atm as I'm at work, but I was thinking you would need a mySQl database of users and resources, coupled with some classes to handle each aspect of the game.
gamer13
Forum Newbie
Posts: 9
Joined: Mon Jan 16, 2006 11:30 am

Post by gamer13 »

phpdevuk wrote:hehe I haven't got time to think too much about this atm as I'm at work, but I was thinking you would need a mySQl database of users and resources, coupled with some classes to handle each aspect of the game.
Ghe ghe, okeej. I'll try. Btw, good luck with your work ;)
gamer13
Forum Newbie
Posts: 9
Joined: Mon Jan 16, 2006 11:30 am

Post by gamer13 »

Question:

How do I get the data from a form. I have this code

Code: Select all

<?
$user="username";
$password="password";
$database="database";
mysql_connect(localhost,$user,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="CREATE TABLE contacts (id int(6) NOT NULL auto_increment,first varchar(15) NOT NULL,last varchar(15) NOT NULL,phone varchar(20) NOT NULL,mobile varchar(20) NOT NULL,fax varchar(20) NOT NULL,email varchar(30) NOT NULL,web varchar(30) NOT NULL,PRIMARY KEY (id),UNIQUE id (id),KEY id_2 (id))";
mysql_query($query);
mysql_close();
?>
You see that it has a TABLE that has as fields inside: First, Last, Phone etc. How do I get that info from a page before?

Code: Select all

Index page = form
Insert page = this page <---- how do I get the info from the form?
It was something like $_Get[post] or something :?
User avatar
phpdevuk
Forum Contributor
Posts: 220
Joined: Mon Jul 04, 2005 5:31 am
Location: UK
Contact:

Post by phpdevuk »

hehe thats a fair way from inputting data from a form :)

I tend to use the format like this, say we have a variable on our form called first, on my index page I would refer to it as $_REQUEST['first']

let me show you an example

the form

Code: Select all

<form action="insert.php" method="post">
<input type="text" name="first" value="">
<input type="submit" name="submit" value="go">
</form>
insert code

Code: Select all

$sql = "INSERT INTO contacts SET first ='".$_REQUEST['first']."'";

mysql_query($sql);
hopefully that makes some sense, thats just a brief example, I'd put all of the db username and passwords into a config file if I was you and just include it at the top of the page.
gamer13
Forum Newbie
Posts: 9
Joined: Mon Jan 16, 2006 11:30 am

Post by gamer13 »

Yup, thnx man. I'd planned that config thing already.
User avatar
phpdevuk
Forum Contributor
Posts: 220
Joined: Mon Jul 04, 2005 5:31 am
Location: UK
Contact:

Post by phpdevuk »

its a good habbit to use the correct way of calling a variable so that you don't mix variables up, e.g

if a variable has come from a post use $_POST['variable']
if a variable is in the URL use $_GET['variable']

the $_REQUEST['variable'] works for either so be careful if you already have a variable with the same name in the url etc.

this is all quite basic stuff tho, you can make things alot more complicated :D
gamer13
Forum Newbie
Posts: 9
Joined: Mon Jan 16, 2006 11:30 am

Post by gamer13 »

Thnx, I have already the register.php file ready. Buzzy with login.php. :D

Again, thnx for the help out here.
Post Reply