Jump to content

staring blind at fetching error


sqlnoob

Recommended Posts

the script:

 

<?php

//CHECKING COOKIE

if (isset($_COOKIE["person"])) {

$you = $_COOKIE['person'];

 

if (isset($_GET["army"])) {

filter_var($_GET["army"], FILTER_SANITIZE_STRING);

$thisarmy = $_GET["army"];

 

//CONNECTOR

$con = mysql_connect("localhost", "username", "password");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

mysql_select_db("shugonl", $con);

 

$resultarm = mysql_query ("SELECT * FROM Armies WHERE ArmyID ='$thisarmy'");

$rowarm = mysql_fetch_array($resultarm);

$whatarmy = $rowarm['Armyname'];

$duty = $rowarm['Armyduty'];

$location = $rowarm['Armylocation'];

$generalnumber = $rowarm['Taisho'];

$general = $rowarm['Generalname'];

$generalyear = $rowarm['Generalbirth'];

$spearmen = $rowarm['Yarigumi'];

$lancers = $rowarm['Nagayarigumi'];

$halberdeers = $rowarm['Naginatagumi'];

$archers = $rowarm['Yumigumi'];

$gunners = $rowarm['Teppogumi'];

$swordsmen = $rowarm['Kengumi'];

$cavalry = $rowarm['Mushagumi'];

$shadowwarrior = $rowarm['Kagemusha'];

$warriormonk = $rowarm['Sohei'];

$mountainwarrior = $rowarm['Yamabushi'];

$mountainascetic = $rowarm['Shugenja'];

$swordsaint = $rowarm['Kenzei'];

$turns = $rowarm['Attackpoint'];

 

//IF GENERAL

if ($generalnumber !=0){

$resgen = mysql_query ("SELECT * FROM Generals WHERE AND GeneralID ='$generalnumber'");

$rowgen = mysql_fetch_array($resgen);

$generalclan = $rowgen['Clan'];

$generalhonor = $rowgen['Honor'];

 

echo "<P class='left'>The ".$whatarmy." army has

<BR>".$spearmen." Yarigumi

<BR>".$lancers." Nagayarigumi

<BR>".$halberdeers." Naginatagumi

<BR>".$archers." Yumigumi

<BR>".$gunners." Teppogumi

<BR>".$swordsmen." Kengumi

<BR>".$cavalry." Mushagumi

<BR>".$shadowwarrior." Kagemusha

<BR>".$warriormonk." Sohei

<BR>".$mountainwarrior." Yamabushi

<BR>".$mountainascetic." Shugenja

<BR>".$swordsaint." Kenzei</P>";

if ($turns ==1){

"<BR>one turn";}

else {

"<BR>no turns";}

 

echo "<P>The army is being led by ".$general." of the ".$generalclan." clan who was born in ".$generalyear." and has ".$generalhonor." honorpoints";

 

$resulttown = mysql_query ("SELECT * FROM Castles WHERE CastleID ='$location'");

$rowtown = mysql_fetch_array($resulttown);

$townowner = $rowtown['Castellan'];

 

if ($townowner ==$you){

echo "<FORM method='Post' action='assigned.php'><INPUT type='hidden' name='assignduty' value='defenders'><INPUT type='Submit' value='garrison' name='submit'></FORM>";

}

else {

echo "<FORM method='Post' action='assigned.php'><INPUT type='hidden' name='assignduty' value='attackers'><INPUT type='Submit' value='attackforce' name='submit'></FORM>";

}

 

 

//ELSE NO GENERAL

}

else {

 

echo "<P class='left'>The ".$whatarmy." army has

<BR>".$spearmen." Yarigumi

<BR>".$lancers." Nagayarigumi

<BR>".$halberdeers." Naginatagumi

<BR>".$archers." Yumigumi

<BR>".$gunners." Teppogumi

<BR>".$swordsmen." Kengumi

<BR>".$cavalry." Mushagumi

<BR>".$shadowwarrior." Kagemusha

<BR>".$warriormonk." Sohei

<BR>".$mountainwarrior." Yamabushi

<BR>".$mountainascetic." Shugenja

<BR>".$swordsaint." Kenzei</P>";

if ($turns ==1){

"<BR>one turn";}

else {

"<BR>no turns";}

echo "<P>The army is not being led by a general

<BR>Please select a clan from which to assign a general to the army

<BR><FORM method='Post' action='aide.php'><SELECT name='generalclan'>";

echo "<option value='" .$you. "'>" .$you. "</option>";

$vassalresult = mysql_query ("SELECT Clan FROM persons WHERE Liege ='$you'");

while($vassalrow = mysql_fetch_array($vassalresult))

{

echo "<option value='" .$vassalrow['Clan']. "'>" .$vassalrow['Clan']. "</option>";

}

echo "</SELECT><input type='hidden' name='armynum' value='".$thisarmy."'><INPUT type='Submit' value='Pick Clan'></FORM>";

}

}

 

}

else {

echo "<BR>No cookie was found";}

?>

 

the table:

 

mysql_select_db("shugonl", $con);

$sqlgen = "CREATE TABLE Generals

(

GeneralID int(7) NOT NULL AUTO_INCREMENT,

PRIMARY KEY(GeneralID),

Clan varchar(20) NOT NULL,

ForeName varchar(6) NOT NULL,

HindName varchar(6) NOT NULL,

Birth int(4) DEFAULT '1999',

Honor int(3) DEFAULT '1',

Titles varchar(7) DEFAULT 'samurai'

)";

mysql_query($sqlgen,$con);

 

 

the problem:

 

Somehow the script is not fetching the data from the Generals table. I know the connector is ok, because it does fetch something from the other tables. I'm staring myself blind as to what I did wrong, from the looks of it it is not a syntax error, because i don't get a white page. Does anyone see the error?

Link to comment
Share on other sites

i was referring to the link with the forum rules

 

quote tags isn't working here for some reason, so please don't mention it thank. I cannot help it, that it does not work.

 

Oh don't they?

 

how about  code tags?

 

//and php tags?

 

 

 

Link to comment
Share on other sites

ahum I meant code tags and yes they don't work. maybe it is because i just came back from the dentist, or maybe it is because friday the 13th is getting close I dunno, but I'm telling you honest to god, no  matter how many gazillions times i push on the code tags, they are not appearing in the text.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.