sqlnoob Posted March 11, 2009 Share Posted March 11, 2009 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? Quote Link to comment Share on other sites More sharing options...
Mchl Posted March 11, 2009 Share Posted March 11, 2009 Read: http://www.phpfreaks.com/page/forum-rules Does this: SELECT * FROM Generals WHERE AND GeneralID ='$generalnumber' look like valid query to you? Quote Link to comment Share on other sites More sharing options...
sqlnoob Posted March 11, 2009 Author Share Posted March 11, 2009 yeah tried that and it isn't working for me. I want to go by the rules, but it just isn't working, no matter how many times i push on the icon. Quote Link to comment Share on other sites More sharing options...
Mchl Posted March 11, 2009 Share Posted March 11, 2009 Of course it is not working. You can not have 'AND' right after 'WHERE'. 'AND' is used for logical conjunction of two conditions, but you have only one (GeneralID ='$generalnumber') Quote Link to comment Share on other sites More sharing options...
sqlnoob Posted March 11, 2009 Author Share Posted March 11, 2009 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. Quote Link to comment Share on other sites More sharing options...
Mchl Posted March 11, 2009 Share Posted March 11, 2009 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? Quote Link to comment Share on other sites More sharing options...
sqlnoob Posted March 11, 2009 Author Share Posted March 11, 2009 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. Quote Link to comment Share on other sites More sharing options...
Mchl Posted March 11, 2009 Share Posted March 11, 2009 Then type em in by yourself. It's 13 keystrokes together. Start your code with and finish with Quote Link to comment Share on other sites More sharing options...
sqlnoob Posted March 11, 2009 Author Share Posted March 11, 2009 yeah if only i can modify it Quote Link to comment Share on other sites More sharing options...
kickstart Posted March 11, 2009 Share Posted March 11, 2009 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. Do you have Javascript turned off? All the best Keith Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.