Thread: MySQL + Arrays?
View Single Post
  #7  
Old 09-30-2011, 06:37 AM
PTGigi's Avatar
PTGigi PTGigi is offline
Crazily Friendly~HoF
 
Join Date: Jul 2009
Location: Somewhere >.>
Posts: 370
Gender: Female
Credits: 27,242
PTGigi
Default

What I mean is if I change
PHP Code:
            //ID ARRAY
            
$input explode(","$adoptid);
            
$rand_keys array_rand($input2);
            
$species $input[$rand_keys[0]]; 
to

PHP Code:
            //ID ARRAY
            
$input explode(","$adoptid);
            
$rand_keys array_rand($input1);
            
$species $input[$rand_keys[0]]; 
The output is nothing. D:

And this is my code: (it's for the Altara site so it's not Mysidia code at all >.<" I hope it's alright to ask for help with that here o-o)
PHP Code:
<?php
define
('IN_PHPBB'true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH './forum/';
$phpEx substr(strrchr(__FILE__'.'), 1);
include(
$phpbb_root_path 'common.' $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
$place $_GET['place'];
?>
<?php 
include('head.html'); 

if (
$place == "center"){
echo 
'Altara - Adoption Center';
}
else if (
$place == "shop"){
echo 
'Altara - Shopping District';
}
else {
echo 
'Altara - Adopt';
}
include(
'head2.html'); 
if (
$place == "center"){
echo 
'Adoption Center';
}
else if (
$place == "shop"){
echo 
'Shopping District';
}
else {
echo 
'Adopt';
}
?>
</h2>
<div class="story">
<p>
<?php
$result 
mysql_query("SELECT * FROM forum_banlist WHERE ban_userid =  ".$user->data['user_id']) or die(mysql_error());
if (
$user->data['user_id'] == ANONYMOUS)
{
   echo 
'Please <a href="http://www.altara.99webs.info/forum/ucp.php?mode=login">login</a> or <a href="http://www.altara.99webs.info/forum/ucp.php?mode=register">register</a> to access more of the site.';
}
else if (
$result == "TRUE"){
   echo 
'You have been banned from access to this site.';
}
else
{
$sql_result mysql_query("SELECT * FROM adopt_user WHERE uid =  '".$user->data['user_id']."'") or die(mysql_error());    
    if(
$sql_result=TRUE){
    
        
$adoptid $_POST['adoptid'];
        
$arraynum $_POST['arraynum'] - 1;
        
$price1 $_POST['price1'];
        
$price2 $_POST['price2'];
    
        
$sql_result mysql_query("SELECT * FROM adopt_user WHERE uid =  '".$user->data['user_id']."'") or die(mysql_error());    
        while(
$row mysql_fetch_array($sql_result))
            {
            
$usercash1 $row['cash'];
            
$usercash2 $row['cash2'];
            }
            
//ID ARRAY
            
$input explode(","$adoptid);
            
$rand_keys array_rand($input2);
            
$species $input[$rand_keys[0]];

        
$result mysql_query("SELECT * FROM adopt_species WHERE id =  '".$adoptid."'") or die(mysql_error());    
        while(
$row mysql_fetch_array($result))
            {
            
$genratio $row['genratio'];
            
$eggimg $row['eggimg'];
            
$hp $row['defhp'];
            
$att $row['defatt'];
            
$def $row['defdef'];
            
$spd $row['defspd'];
            
$trade $row['trade'];
            
$breed $row['breed'];
            
$limit $row['ownlimit'];
            
$itemup $row['itemup'];
            
$tradeup $row['tradeup'];
            
$friendup $row['friendup'];
            
$growthrate $row['growthrate'];
            
$specname $row['name'];
            }
        
$newcash1 $usercash1 $price1;
        
$newcash2 $usercash2 $price2;
        
        if (
$newcash1 || $newcash2 0){
            
//GENDERS
            
if ($genratio == "male"){
                
$gender "Male";
            }
            else if (
$genratio == "female"){
                
$gender "Female";
            }
            else if (
$genratio == "moremale"){
                
$rand rand(1,4);
                if (
$rand == 1){
                    
$gender "Female";
                }
                else {
                    
$gender "Male";
                }
            }
            else if (
$genratio == "morefemale"){
                
$rand rand(1,4);
                if (
$rand == 1){
                    
$gender "Male";
                }
                else {
                    
$gender "Female";
                }
            }
            else if (
$genratio == "50"){
                
$rand rand(0,1);
                if (
$rand == 1){
                    
$gender "Female";
                }
                else {
                    
$gender "Male";
                }
            }
            else {
                
$gender "Ungendered";
            }
            
//NATURES
            
$input = array("Bossy""Brave""Calm""Cautious""Curious""Deceitful""Docile""Excitable""Loyal""Funny""Hardy""Hasty""Kind""Lonely""Modest""Moody""Naive""Nervous""Quiet""Quirky""Rash""Reserved""Serious""Shy""Sincere");
            
$rand_keys array_rand($input2);
            
$nature $input[$rand_keys[0]];

            
mysql_query("INSERT INTO adopt_adopts VALUES ('0','".$user->data['user_id']."', 'Unnamed', '".$gender."', '".$nature."', '".$hp."', '".$hp."', '".$att."', '".$def."', '".$spd."', '0', '0', '".$eggimg."', '".$species."', '".$trade."', '".$breed."', '0', '0', '".$user->data['user_id']."', '0', '0', '0', '".$itemup."', '".$tradeup."', '".$friendup."', '".$growthrate."', '".$specname."')") or die(mysql_error());
            
//id,owner,name,gender,nature,currenthp,maxhp,att,def,spd,stage,exp,image,species,trade,breed,traded,friendship,ot,mother,father,group,itemup,tradeup,friendup,growthrate, speciesname
            
$newid mysql_insert_id();        
            echo
'<p><strong>Congrats!</strong> You\'ve just recieved a new egg! </p>
            <img src="'
.$eggimg.'">
            <p>You can click <a href="/feed.php?id='
.$newid.'">here</a> to warm the egg and help it grow, or you can click <a href="/creature.php?id='.$newid.'">here</a> to view the newly recieved egg.</p>';
        }
        else {
            echo 
'Sorry there was an issue! Please try again. If the problem persists, contact the Admin or ask for help on the forums';
        }
    }
    else {
       echo 
$user->data['username'] . ' you have NOT completed registration! Please go <a href="/complete.php">here</a> to complete your registration to fully access the adoptable portion of this site.';
    }
}
?>
<?php 
include('foot.html'); ?>
I haven't gotten around to checking that link out, but I should be able to during school today :3
__________________


"I see now that the circumstances of one's birth are irrelevant; it is what you do with the gift of life that determines who you are."~Mewtwo
My Adoptables|Nuzlocke Webcomic
Reply With Quote