DEVILofDARKNESS
Members-
Posts
502 -
Joined
-
Last visited
Never
Everything posted by DEVILofDARKNESS
-
[SOLVED] 2 Files, URL and Variable problem!
DEVILofDARKNESS replied to erme's topic in PHP Coding Help
ofcourse, it should be: $query = "SELECT * FROM locations $_SESSION['extrapart']"; and if that doesn't work: $extrapart = $_SESSION['extrapart']; $query = "SELECT * FROM locations $extrapart"; BTW don't forget to include as first line above the html in your php: session_start(); And I think something is wrong with your query: SELECT * FROM locations $extrapart what should the variable extrapart contain? -
[SOLVED] 2 Files, URL and Variable problem!
DEVILofDARKNESS replied to erme's topic in PHP Coding Help
you can store it in a session, or in a cookie -
[SOLVED] Help needed with dynamic title tags
DEVILofDARKNESS replied to pixelhouse's topic in PHP Coding Help
SOrry I didn't show it in my code example, but if you want to show the content of a variable (in this case $p_name) you should do: <? echo $p_name; ?> or <? print $p_name; ?> -
[SOLVED] Help needed with dynamic title tags
DEVILofDARKNESS replied to pixelhouse's topic in PHP Coding Help
you only have to do: <html> <head> <title><? $productname ?></title> </head> <body> ... </body> </html> -
[SOLVED] Only one row is showed
DEVILofDARKNESS replied to DEVILofDARKNESS's topic in PHP Coding Help
It's solved Thanks -
php form not posting into my file
DEVILofDARKNESS replied to PlagueInfected's topic in PHP Coding Help
That link doesn't work in my browser... -
[SOLVED] Only one row is showed
DEVILofDARKNESS replied to DEVILofDARKNESS's topic in PHP Coding Help
Sorry the databases are this: region_weapons region_id weapon_id ammount 1-------------1-------------5 2-------------1-------------0 1-------------2-------------2 weapons Attachment. [attachment deleted by admin] -
I've the following text file: config.ssa editor: gedit filepath: /home/darragh/Documenten/D_MENU/files I want to grab the string after editor (=gedit) with java I've found this: logdialtext = "Where is the configurationfile located? \n(whole the path)"; String configpath = WelcomeMsg.showInputDialog(logdialtext); Scanner sc = new Scanner(configpath); sc.findInLine("editor:"); if (sc.hasNext()) { WelcomeText.setText(sc.next()); } else { WelcomeText.setText("Error!"); } When I insert the path in the dialog, it just shows the path I insert into the WelcomeText; textbox I think the problem is that it doesn't read the content from the configpath, but only the name. How can I solve this? (I got this script from: java2s.com)
-
php form not posting into my file
DEVILofDARKNESS replied to PlagueInfected's topic in PHP Coding Help
That's all true , and I also believe that the 'and' should dissapear and just do the include on the next line just as Tendola said. -
php form not posting into my file
DEVILofDARKNESS replied to PlagueInfected's topic in PHP Coding Help
In first place I would copy-paste the php code above the actually html code, (this will probably not change the effect, but it's more clean the $file_name contains a $ inside the quotes, is this possible? -
In the following code only one row is showen, although I know their are at least 2 rows that should be displayed. this is the database: region_id nation_id ammount 1--------------17----------5 2--------------18----------2 3--------------17----------2 (Like you can see If I run the code with nation_id 17 I should receive 2 outputs...) $query = "SELECT * FROM regions WHERE nation_id='$nationid'"; $result = mysql_query($query); $numrows = mysql_num_rows($result); if($numrows > 0){ while($region = mysql_fetch_array($result)){ $query2 = "SELECT * FROM region_weapons INNER JOIN weapons ON region_weapons.weapon_id = weapons.weapon_id WHERE region_id = '" . $region['region_id'] . "'"; $result2 = mysql_query($query2); $YW = mysql_fetch_assoc($result2); echo "<div id='attack_left'>" . $YW['weapon_name'] . "</div><div id='attack_right'>" . $YW['ammount'] . "</div>"; } }else{ echo "<div id='attack_center'>This nation doesn't have any weapons...</div>"; }
-
[SOLVED] Unsuported operand types?
DEVILofDARKNESS replied to DEVILofDARKNESS's topic in PHP Coding Help
Thanks I only tried the last solution by J.Daniels, and it worked probably the other solutions worked as well but I will stick with this one untill it fails too -
I get the error Unsupported operand types?! How can I solve this? (the error said it was on the last line from the foll. code) $query = "SELECT ammount FROM " . $CoRTable . " WHERE (weapon_id = '$weaponid') AND (" . $CoRIdName . " = '$CoRId')"; $result = mysql_query($query); if(mysql_num_rows($result) == 1){ $curramm = mysql_fetch_row($result); $ammount = $_POST['ammount'] + $curramm;
-
Thanks
-
It's the first time I used regex, so before I launch it on the WWW, I want to know if it's well formed and safe. (It's an easy one, to check if the ammount of a textbox is a value above 0) preg_match("/^[^-]?[1-9]+/", $_POST['ammount'], $matches)
-
Smart
-
Well it's quit difficult to do that, because the php will think I'm closing the switch statement: switch($type){ case weapon: $name = $_GET['name']; $query = "SELECT * FROM weapons"; $result = mysql_query($query); while($InfWeap = mysql_fetch_array($result)){ switch($name){ case $InfWeap['weapon_short_name']: echo "Full Name: " . $InfWeap['weapon_name'] . "<br>Short Name: " . $InfWeap['weapon_short_name']; break; } default: echo "Default"; } break;
-
Okay that works, thanks If I exactly copy like you 'wrote' it, I get a lot of: defaults between the normal text, if I use the same code except I don't use default: echo "Default", then I get the right text, Is there a way that I can implement the default: ?
-
There is this page: weapons.php The main part is coded: echo "Welcome in the weapon-section.<br><br> Our Weapons:<br><br>"; $query = "SELECT * FROM weapons WHERE shop='WOSH'"; $result = mysql_query($query); while($WOSHWeapons = mysql_fetch_array($result)){ echo "<a href='./info.php?type=weapon&name=" . $WOSHWeapons['weapon_short_name'] . "'>" . $WOSHWeapons['weapon_name'] . "</a><br>"; } So If you click on a link you go to ./info.php?type=weapon&name=//shortname On info.php I can handle this information easy by using switch(){case ... } But If I have a lot of weapons, I will have to write a lot of case ...: break; So I tried: <?php $type = $_GET['type']; switch($type){ case weapon: $name = $_GET['name']; $query = "SELECT * FROM weapons"; $result = mysql_query($query); switch($name){ while($InfWeap = mysql_fetch_array($result)){ case $InfWeap['weapon_short_name']: echo "Full Name: " . $InfWeap['weapon_name'] . "<br>Short Name: " . $InfWeap['weapon_short_name']; break; } default: echo "Default"; } break; It doesn't work because I use a while loop inside a switch loop Is there a certain way to do this, if there isn't please tell me an easier method to show the info about the weapons. BTW: It's about a futuristic game, not a weapon shop
-
If I run this script with user Test that has leader: no, I get: This nation doesn't have any weapons. Although I should get This: You don't have any weapons... I echoed $leader on an other page and it gave as output: no (which it should be), but if I echo it on the page it gives: yes although it is the same code which generates if it is a leader or not. I'm a bit confused??? (You should actually only see to the last lines of the code, not to the query, the query is only loaded when there are results found, in this case their aren't...) weapons.php <?php session_start(); require_once './config.php'; require_once './checkuserid.php'; $query = "SELECT leader FROM users WHERE user_id = '$userid'"; $result = mysql_query($query); list($leader) = mysql_fetch_row($result); /* CoRTable = Civilian or Ruler Table: Civilians: user_weapons Rulers: region_weapons CoRIdName: Civilian: user_id Ruler: nation_id CoRId; The Id from the user or nation YW: YourWeapons */ if($leader = 'yes'){ $CoRTable = "region_weapons"; $CoRIdName = "region_id"; $CoRId = $nationid; }else{ $CoRTable = "user_weapons"; $CoRIdName = "user_id"; $CoRId = $userid; } ?> <html> <head> <title>CriticalInvasion - Weapons</title> <link href="./css/index.css" rel="stylesheet" type="text/css"> </head> <body> <?php $query = "SELECT * FROM " . $CoRTable . " INNER JOIN weapons ON " . $CoRTable . ".weapon_id = weapons.weapon_id WHERE " . $CoRIdName . " = '$CoRId'"; $result = mysql_query($query); $numrows = mysql_num_rows($result); if($numrows > 0){ while($YW = mysql_fetch_array($result)){ echo "<div id='attack_left'>" . $YW['weapon_name'] . "</div><div id='attack_right'>" . $YW['ammount'] . "</div>"; } }elseif(($numrows <= 0) && ($leader = 'yes')){ echo "<div id='text_text'>This nation doesn't have any weapons...</div>"; }elseif(($numrows <= 0) && ($leader = 'no')){ echo "<div id='text_text'>You don't have any weapons...</div>"; } ?> </body> </html> edit.php <?php session_start(); require_once './config.php'; require_once './checkuserid.php'; $query = "SELECT leader FROM users WHERE user_id = '$userid'"; $result = mysql_query($query); list($leader) = mysql_fetch_row($result); ?> <html> <head> <title>CriticalInvasion - Edit</title> <link href="./css/index.css" rel="stylesheet" type="text/css"> </head> <body> <div id='text_text'> <? echo $userid . " " . $leader; ?> </div> </body> </html>
-
I've found it, it was because my form tag was before the div tag. SOLVED.
-
Insert into database without moving to different page
DEVILofDARKNESS replied to FUNKAM35's topic in PHP Coding Help
What's so difficult about it? <?php ... If(isset($_POST['submit']){ $query = "..."; $result = mysql_query($query); ... } ... ?> <html> <head> ... </head> <body> ... <form action='post'> ... <input type='submit' name='submit'> </form> ... </body> </html> -
Like you can see on the attachments I have a frame on the left (also on the right but that doesn't matter now), on every tab from that frame I click, the frame is printed out like it should, only if I click on attack it isn't printed out like it should (you can see that only a part of the frame is visible). I will include the code, maybe someone can help me. (I didn't include the php because I think that will not affect the css or the html) attack.php <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>ATTACK!</title> <link href="./css/index.css" rel="stylesheet" type="text/css"> <link href="./css/attack.css" rel="stylesheet" type="text/css"> </head> <body> <div id="box"> <form action='' method='post'> <div id="header"> ATTACK </div> <div id="left_navigation"> <iframe src='./navleft.php' height='100%' width='100%' frameborder="0" scrolling="No"></iframe> </div> <div id="main_overview"> <div class="attack_header"> Step 1: Choose Your Target </div> <div class="attack_text"> <?php while(...){ // NYAR Not Your Active Regions echo "<div class='attack_left'>" . $NYAR['region_name'] . "</div><div class='attack_right'><input type='radio' name='radioNYAR' value='" . $NYAR['region_id'] . "'></div>"; } ?> </div> <?php if($region = "visible"){ ?> <div class='attack_header'> Step 2: Choose the region from where you want to attack </div> <?php if(...){echo "<div class='attack_left'>" . $YAR['region_name'] . "</div><div class='attack_right'><input type='radio' name='radioYAR' value='" . $YAR['region_id'] . "'></div>"; }else{ echo "<div class='attack_center'>Oops You Don't have any regions</div>"; } ?> <div class='attack_header'> Step <?php echo $stepnext; ?>: Next! </div> <div class='attack_center'> <input type='submit' name='submit' value='Next!'> </div> </div> <div id="right_navigation"> <iframe src="./navright.php" frameborder="0" width="100%" height="100%" scrolling="No"></iframe> </div> <div id="footer_overview"> <iframe src="./footernav.php" frameborder='0' width="100%" height="100%" scrolling="No"></iframe> </div> </form> </div> </body> </html> overview.php (first image) <html> <head> <title>CriticalInvasion - Overview</title> <link href="./css/index.css" rel="stylesheet" type="text/css"> </head> <body> <div id="box"> <div id="header"> Overview </div> <div id="left_navigation"> <iframe src='./navleft.php' height='100%' width='100%' frameborder="0" scrolling="No"></iframe> </div> <div id="main_overview"> <div id="events_header"> Last Events </div> <div id="events_nation"> <?php while(...){ echo $natevents['e_n_type'] . "<br>"; } echo "<p>"; ?> </div> <div id="events_alliance"> <?php while(...){ echo $allevents['e_a_type'] . "<br>"; } ?> </div> </div> <div id="right_navigation"> <iframe src="./navright.php" frameborder="0" width="100%" height="100%" scrolling="No"></iframe> </div> <div id="footer_overview"> <iframe src="./footernav.php" frameborder='0' width="100%" height="100%" scrolling="No"></iframe> </div> </div> </body> </html> index.css * { margin: 0; padding: 0; text-align: center; font-family: 'Times New Roman'; /* border-style: solid; border-width: 1px; border-color: red; */ } body { color: #FFFFFF; width: 100%; height: 100%; background-color: #000000; } /************************* ID's *************************/ #box { width:100%; height:100%; } #header { color: red; text-decoration: underline; width: 100%; height: 5%; text-align: center; font-size: 15pt; font-weight: bold; } #navigation { float: left; text-align: center; width: 90px; height: 90%; margin: 15px 10px 0 50px; } #left_navigation { float: left; text-align: center; width: 90px; height: 75%; margin: 10px 10px 0 50px; } #main { float: left; text-align: center; margin-top: 15px; padding-top: 50px; width: 80%; height: 80%; } #main_overview { float: left; text-align: center; margin-top: 10px; width: 75%; height: 75%; } #events_header { text-align: center; width: 100%; height: 10%; } #events_nation{ text-align: center; width: 100%; height: 45%; } #events_alliance{ text-align: center; width: 100%; height: 45%; } #right_navigation { float: right; text-align: center; width: 90px; height: 75%; margin-top: 10px; margin-left: 10px; margin-right: 50px; } #footer { float: left; text-align: center; width: 100%; height: 9%; } #footer_overview { float: left; text-align: center; width: 100%; height: 14%; } #text_header { font-style: italic; text-decoration: underline; margin-top: 15px; margin-bottom: 12px; } #text_text { font-style: normal; text-decoration: normal; } /***************** Classes ******************/ h2.nav { height: 30px; font-size: 14pt; border-style: solid; border-color: white; border-width: 1px; padding-top: 2px; padding-bottom: 2px; font-weight: bold; text-align: center; } h2.fnav { height: 15px; font-size: 12pt; font-weight: bold; } h2.ranks { height: 20px; font-size: 15pt; font-weight: bold; border-style: solid border-width: 1px; border-color: white; } li.nav { height: 26px; list-style-type: none; font-size: 11pt; border-style: solid; border-color: gray; border-width: 1px; padding-top: 2px; padding-bottom: 2px; text-align: center; } li.nav2 { list-style-type: none; height: 0px; } li.ranks { list-style-type: none; height: 30px; font-size: 12pt; border-style: solid; border-color: gray; border-width: 1px; font-weight: normal; } h3.rnav { height: 30px; font-size: 11pt; border-style: solid; border-color: gray; border-width: 1px; padding-top: 2px; padding-bottom: 2px; font-weight: normal; } h3.fnav { height: 15px; font-size: 11pt; font-weight: normal; } h3.ranks { height: 30px; font-size: 12pt; font-weight: normal; } img.rnav { height: 30px; width: 100px; border-style: solid border-color: white border-width: 1px; padding-top: 2px; padding-bottom: 2px; } a:link { color: #FFFFFF; } a:visited { color: #FFFFFF; } a:active { color: #FFFFFF; } a:hover { color: #FFFFFF; } attack.css div.attack_header { float: left; font-weight: bold; height: 25px; width: 100%; margin-top: 15px; margin-bottom: 15px; } div.attack_left { float: left; height: 25px; width: 70%; } div.attack_right { float: left; height: 25px; width: 30%; } div.attack_center { float: left; height: 25px; width: 100%; } I hope there is someone who could explain what I've done wrong... [attachment deleted by admin]
-
Ofcourse I did, ! Okay I don't use a background image to make the rows same height,... maybe I should try that out first.