Select List not Working - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Select List not Working

darthmoobeydarthmoobey Posts: 140Member
Hello folks, there are two things I was hoping to get help with. First I have used this code to try and make an easier array for storing data in my DB. The problem is when I open the page, there are no errors, everything looks and loads great, just the Selector Lists, the drop down lists do not show any data. Could someone maybe look at my code and see, why? 2) I have tried using the include command, to refer to the database config data, username, host, and pw info but it would not load it. I went ahead and placed it on the page itself, but I was hoping to make an include reference, instead of imbedding it in the page. Is my include callout correct, or do I need two // before the directory callout?

Thank you very much
The Darthmoob

[code]
<?php
include('/php/config.php');


$connect=mysql_connect($host,$user,$pw);
echo mysql_error();
mysql_select_db($db);

//Code created and referred by Skylar the Great
function arrayFill($start, $len, $value){
$newarr = array();
$end = $start + $len;
if(!$len){return;}
for($i=$start; $i<$end; $i++){
$newarr[$i] = $value;
}
return $newarr;
}
//Code created and referred by Skylar the Great
if(!isset($mental)){$mental = arrayFill(0, 3, 1);}
if(!isset($social)){$social = arrayFill(0, 3, 1); $social[2] = 0;}
if(!isset($physical)){$physical = arrayFill(0, 3, 1);}

if(!isset($know)){$know = arrayFill(0, 13, 0);}
if(!isset($talent)){$talent = arrayFill(0, 13, 0);}
if(!isset($skill)){$skill = arrayFill(0, 13, 0);}
//Code created and referred by Skylar the Great
function optionCreator($start, $end, $selected){
$str = '';
for($i=$start; $i<$end+1; $i++){
$select = '';
if($i == $selected){$select = ' SELECTED';}
$str .= "<option value=$i$select>$i";
}
return $str;
}
//Code created and referred by Skylar the Great
//START SELECT(S) HANDLING STRINGS

$physicalselect=array();
$physicalselect[0]=optionCreator(1,9,$physical[0]);
$physicalselect[1]=optionCreator(1,9,$physical[1]);
$physicalselect[2]=optionCreator(1,9,$physical[2]);

$socialselect=array();
$socialselect[0]=optionCreator(1,9,$social[0]);
$socialselect[1]=optionCreator(1,9,$social[1]);
$socialselect[2]=optionCreator(1,9,$social[2]);

$mentalselect=array();
$mentalselect[0]=optionCreator(1,9,$mental[0]);
$mentalselect[1]=optionCreator(1,9,$mental[1]);
$mentalselect[2]=optionCreator(1,9,$mental[2]);

$talentselect=array();
$talentselect[0]=optionCreator(1,9,$talent[0]);
$talentselect[1]=optionCreator(1,9,$talent[1]);
$talentselect[2]=optionCreator(1,9,$talent[2]);
$talentselect[3]=optionCreator(1,9,$talent[3]);
$talentselect[4]=optionCreator(1,9,$talent[4]);
$talentselect[5]=optionCreator(1,9,$talent[5]);
$talentselect[6]=optionCreator(1,9,$talent[6]);
$talentselect[7]=optionCreator(1,9,$talent[7]);
$talentselect[8]=optionCreator(1,9,$talent[8]);
$talentselect[9]=optionCreator(1,9,$talent[9]);

$skillselect=array();
$skillselect[0]=optionCreator(1,9,$skill[0]);
$skillselect[1]=optionCreator(1,9,$skill[1]);
$skillselect[2]=optionCreator(1,9,$skill[2]);
$skillselect[3]=optionCreator(1,9,$skill[3]);
$skillselect[4]=optionCreator(1,9,$skill[4]);
$skillselect[5]=optionCreator(1,9,$skill[5]);
$skillselect[6]=optionCreator(1,9,$skill[6]);
$skillselect[7]=optionCreator(1,9,$skill[7]);
$skillselect[8]=optionCreator(1,9,$skill[8]);
$skillselect[9]=optionCreator(1,9,$skill[9]);

$knowselect=array();
$knowselect[0]=optionCreator(1,9,$know[0]);
$knowselect[1]=optionCreator(1,9,$know[1]);
$knowselect[2]=optionCreator(1,9,$know[2]);
$knowselect[3]=optionCreator(1,9,$know[3]);
$knowselect[4]=optionCreator(1,9,$know[4]);
$knowselect[5]=optionCreator(1,9,$know[5]);
$knowselect[6]=optionCreator(1,9,$know[6]);
$knowselect[7]=optionCreator(1,9,$know[7]);
$knowselect[8]=optionCreator(1,9,$know[8]);
$knowselect[9]=optionCreator(1,9,$know[9]);


if($submit){
$mysqlphysical=implode("|",$physical);
$mysqlsocial=implode("|",$social);
$mysqlmental=implode("|",$mental);
$mysqltalents=implode("|",$talent);
$mysqlskills=implode("|",$skill);
$mysqlknows=implode("|",$know);
switch(gen){
case 13:
$blood="10";
break;
case 12:
$blood="11";
break;
case 11:
$blood="12";
break;
case 10:
$blood="13";
break;
case 9:
$blood="14";
break;
case 8:
$blood="15";
break;
case 7:
$blood="20";
break;
case 6:
$blood="30";
break;
case 5:
$blood="40";
break;
}//end of Case Switch for Determining Blood Pool

$r="INSERT INTO $table SET
CharName='$charname',
Type='$type',
Gen='$gen',
Sect='$sect',
Concept='$concept',
Sex='$sex',
URL='$url',
Age1='$age1',
Age2='$age2',
Nature='$nature',
Demeanor='$demeanor',
Description='$description',
Physicals='$mysqlphysical',
Socials='$mysqlsocial',
Mentals='$mysqlmental',
Talents='$mysqltalents',
Skills='$mysqlskills',
Knowledges='$mysqlknows',
Secondary='$second',
Backgrounds='$backs',
Disciplines='$powers',
MF='$merits',
Willpower='$willpower',
Path='$path',
pathrate='$pathrate',
Blood='$blood',
Virtue1='$virtue1',
Virtue2='$virtue2',
Virtue3='$virtue3',
Equipment='$equipment',
Notes='$notes'";

$result=mysql_query($r);
if($result){
echo

Success!! Your Character was Successfully Created.


You may now close this window.

eof;
exit;
}
else{
echo"
Failure! ! Mysql Error Says:

".mysql_error()."
";
}
}
?>
[/code]


Comments

  • DarQDarQ Posts: 1,625Member
    i'm very tired so i didnt really look at your questions and code. but i did see your second question (about the include) and it spotted some unusual stuff in one of your first lines.

    include('/php/config.php');

    your second line. i am quite sure that the leading slash should not be there. a path that begins with a slash looks like a typical unix filesystem, and since when does an unix like OS have a php directory in the root??

    so remove that slash and try again

    : Hello folks, there are two things I was hoping to get help with. First I have used this code to try and make an easier array for storing data in my DB. The problem is when I open the page, there are no errors, everything looks and loads great, just the Selector Lists, the drop down lists do not show any data. Could someone maybe look at my code and see, why? 2) I have tried using the include command, to refer to the database config data, username, host, and pw info but it would not load it. I went ahead and placed it on the page itself, but I was hoping to make an include reference, instead of imbedding it in the page. Is my include callout correct, or do I need two // before the directory callout?
    :
    : Thank you very much
    : The Darthmoob
    :
    : [code]
    : <?php
    : include('/php/config.php');
    :
    :
    : $connect=mysql_connect($host,$user,$pw);
    : echo mysql_error();
    : mysql_select_db($db);
    :
    : //Code created and referred by Skylar the Great
    : function arrayFill($start, $len, $value){
    : $newarr = array();
    : $end = $start + $len;
    : if(!$len){return;}
    : for($i=$start; $i<$end; $i++){
    : $newarr[$i] = $value;
    : }
    : return $newarr;
    : }
    : //Code created and referred by Skylar the Great
    : if(!isset($mental)){$mental = arrayFill(0, 3, 1);}
    : if(!isset($social)){$social = arrayFill(0, 3, 1); $social[2] = 0;}
    : if(!isset($physical)){$physical = arrayFill(0, 3, 1);}
    :
    : if(!isset($know)){$know = arrayFill(0, 13, 0);}
    : if(!isset($talent)){$talent = arrayFill(0, 13, 0);}
    : if(!isset($skill)){$skill = arrayFill(0, 13, 0);}
    : //Code created and referred by Skylar the Great
    : function optionCreator($start, $end, $selected){
    : $str = '';
    : for($i=$start; $i<$end+1; $i++){
    : $select = '';
    : if($i == $selected){$select = ' SELECTED';}
    : $str .= "<option value=$i$select>$i";
    : }
    : return $str;
    : }
    : //Code created and referred by Skylar the Great
    : //START SELECT(S) HANDLING STRINGS
    :
    : $physicalselect=array();
    : $physicalselect[0]=optionCreator(1,9,$physical[0]);
    : $physicalselect[1]=optionCreator(1,9,$physical[1]);
    : $physicalselect[2]=optionCreator(1,9,$physical[2]);
    :
    : $socialselect=array();
    : $socialselect[0]=optionCreator(1,9,$social[0]);
    : $socialselect[1]=optionCreator(1,9,$social[1]);
    : $socialselect[2]=optionCreator(1,9,$social[2]);
    :
    : $mentalselect=array();
    : $mentalselect[0]=optionCreator(1,9,$mental[0]);
    : $mentalselect[1]=optionCreator(1,9,$mental[1]);
    : $mentalselect[2]=optionCreator(1,9,$mental[2]);
    :
    : $talentselect=array();
    : $talentselect[0]=optionCreator(1,9,$talent[0]);
    : $talentselect[1]=optionCreator(1,9,$talent[1]);
    : $talentselect[2]=optionCreator(1,9,$talent[2]);
    : $talentselect[3]=optionCreator(1,9,$talent[3]);
    : $talentselect[4]=optionCreator(1,9,$talent[4]);
    : $talentselect[5]=optionCreator(1,9,$talent[5]);
    : $talentselect[6]=optionCreator(1,9,$talent[6]);
    : $talentselect[7]=optionCreator(1,9,$talent[7]);
    : $talentselect[8]=optionCreator(1,9,$talent[8]);
    : $talentselect[9]=optionCreator(1,9,$talent[9]);
    :
    : $skillselect=array();
    : $skillselect[0]=optionCreator(1,9,$skill[0]);
    : $skillselect[1]=optionCreator(1,9,$skill[1]);
    : $skillselect[2]=optionCreator(1,9,$skill[2]);
    : $skillselect[3]=optionCreator(1,9,$skill[3]);
    : $skillselect[4]=optionCreator(1,9,$skill[4]);
    : $skillselect[5]=optionCreator(1,9,$skill[5]);
    : $skillselect[6]=optionCreator(1,9,$skill[6]);
    : $skillselect[7]=optionCreator(1,9,$skill[7]);
    : $skillselect[8]=optionCreator(1,9,$skill[8]);
    : $skillselect[9]=optionCreator(1,9,$skill[9]);
    :
    : $knowselect=array();
    : $knowselect[0]=optionCreator(1,9,$know[0]);
    : $knowselect[1]=optionCreator(1,9,$know[1]);
    : $knowselect[2]=optionCreator(1,9,$know[2]);
    : $knowselect[3]=optionCreator(1,9,$know[3]);
    : $knowselect[4]=optionCreator(1,9,$know[4]);
    : $knowselect[5]=optionCreator(1,9,$know[5]);
    : $knowselect[6]=optionCreator(1,9,$know[6]);
    : $knowselect[7]=optionCreator(1,9,$know[7]);
    : $knowselect[8]=optionCreator(1,9,$know[8]);
    : $knowselect[9]=optionCreator(1,9,$know[9]);
    :
    :
    : if($submit){
    : $mysqlphysical=implode("|",$physical);
    : $mysqlsocial=implode("|",$social);
    : $mysqlmental=implode("|",$mental);
    : $mysqltalents=implode("|",$talent);
    : $mysqlskills=implode("|",$skill);
    : $mysqlknows=implode("|",$know);
    : switch(gen){
    : case 13:
    : $blood="10";
    : break;
    : case 12:
    : $blood="11";
    : break;
    : case 11:
    : $blood="12";
    : break;
    : case 10:
    : $blood="13";
    : break;
    : case 9:
    : $blood="14";
    : break;
    : case 8:
    : $blood="15";
    : break;
    : case 7:
    : $blood="20";
    : break;
    : case 6:
    : $blood="30";
    : break;
    : case 5:
    : $blood="40";
    : break;
    : }//end of Case Switch for Determining Blood Pool
    :
    : $r="INSERT INTO $table SET
    : CharName='$charname',
    : Type='$type',
    : Gen='$gen',
    : Sect='$sect',
    : Concept='$concept',
    : Sex='$sex',
    : URL='$url',
    : Age1='$age1',
    : Age2='$age2',
    : Nature='$nature',
    : Demeanor='$demeanor',
    : Description='$description',
    : Physicals='$mysqlphysical',
    : Socials='$mysqlsocial',
    : Mentals='$mysqlmental',
    : Talents='$mysqltalents',
    : Skills='$mysqlskills',
    : Knowledges='$mysqlknows',
    : Secondary='$second',
    : Backgrounds='$backs',
    : Disciplines='$powers',
    : MF='$merits',
    : Willpower='$willpower',
    : Path='$path',
    : pathrate='$pathrate',
    : Blood='$blood',
    : Virtue1='$virtue1',
    : Virtue2='$virtue2',
    : Virtue3='$virtue3',
    : Equipment='$equipment',
    : Notes='$notes'";
    :
    : $result=mysql_query($r);
    : if($result){
    : echo<<<eof
    : <center>
    : Success!! Your Character was Successfully Created.


    : You may now close this window.
    :
    : eof;
    : exit;
    : }
    : else{
    : echo"Failure! ! Mysql Error Says:

    ".mysql_error()."";
    : }
    : }
    : ?>
    : [/code]
    :
    :
    :

    [size=5][italic][blue]Dar[RED]Q[/RED][/blue][/italic][/size]
    Jou my no rap dy lekkere dikke tsjap

Sign In or Register to comment.