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
https://forums.phpfreaks.com/topic/148933-staring-blind-at-fetching-error/
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?

 

 

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.