Page 1 of 2

Earn Resources

Posted: Mon Jan 16, 2006 11:35 am
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

Posted: Mon Jan 16, 2006 11:58 am
by phpdevuk
are you talking about some kind of game?

Posted: Mon Jan 16, 2006 12:42 pm
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...

Posted: Tue Jan 17, 2006 12:35 am
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...

Posted: Tue Jan 17, 2006 3:18 am
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?

Posted: Tue Jan 17, 2006 8:06 am
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

Posted: Tue Jan 17, 2006 8:10 am
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.

Posted: Tue Jan 17, 2006 8:13 am
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

Posted: Tue Jan 17, 2006 8:25 am
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.

Posted: Tue Jan 17, 2006 8:30 am
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 ;)

Posted: Tue Jan 17, 2006 8:45 am
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 :?

Posted: Tue Jan 17, 2006 9:08 am
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.

Posted: Tue Jan 17, 2006 9:16 am
by gamer13
Yup, thnx man. I'd planned that config thing already.

Posted: Tue Jan 17, 2006 9:24 am
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

Posted: Tue Jan 17, 2006 9:34 am
by gamer13
Thnx, I have already the register.php file ready. Buzzy with login.php. :D

Again, thnx for the help out here.