designing a peon maker
Posted: Thu May 25, 2006 2:55 pm
Jcart | Please use

Jcart | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
basically im trying to create a script that makes peons... of both male and female but for some reason i always end up with male peons... (reasons unknow either rand is not working or something is auto switching to male ) not a great this when i plan to add a later script that allows peons over a certain age to procreate... so any ideas as to what is wrong?
this script is a modular include file so for testing purposes all the variables i can call are listed in the beginning then i will include it in its proper place once i know it works...Code: Select all
<?
include('DB.php');
ConnectToDB();
function peonborn()
{
$username = "Freddy";
$peonage = 1;
$peonjob = "none";
$peonmoney = 0;
$peonsex = rand(0,1);
if($peonsex = 1)
{$peonsex = "m" ;}
else { $peonsex = "f" ; }
if($peonsex = "m")
{
$array = file("MaleFirstNames.txt");
shuffle($array);
for ($i=0; $i<1; $i++) {
echo $array[$i];
$PEONSQL = "INSERT into peons(user,name,sex,age,job,money,moneylast,buildingno) VALUES ('$username','$array[$i]', '$peonsex','$peonage','$peonjob','$peonmoney','0','0')";
mysql_query($PEONSQL) or die("could not insert into table peons");
}
}
else
{
$array = file("FemaleFirstNames.txt");
shuffle($array);
for ($i=0; $i<1; $i++) {
echo $array[$i];
$PEONSQL = "INSERT into peons(user,name,sex,age,job,money,moneylast,buildingno) VALUES ('$username','$array[$i]', '$peonsex','$peonage','$peonjob','$peonmoney','0','0')";
mysql_query($PEONSQL) or die("could not insert into table peons");
}
}
}
function insertpeonvalues()
{
$PEONSQL = "INSERT into peons(user,name,sex,age,job,money,moneylast,buildingno) VALUES ('$username','$peonname', '$peonsex','$peonage','$peonjob','$peonmoney','0','0')";
mysql_query($PEONSQL) or die("could not insert into table peons");
}
peonborn();
//insertpeonvalues();
?>Jcart | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]