Jump to content

Ryflex

Members
  • Posts

    115
  • Joined

  • Last visited

Everything posted by Ryflex

  1. Hi all, I have an array $n[] and have made a DB query with fetch_array ($result[]). Now I'm trying to get the information out of the $result[] with $n[] so I made the following and it doesn't work. I checked if they're filled and they are and when I enter in the $result[] array with hardcoded info I do get what I need but I need it trough the array... Can anyone help me out?? Thnx Ryflex $sql = "SELECT * FROM units WHERE member_id = '$member_ID'"; $result = mysql_fetch_array(mysql_query($sql)) or die("Could not find amount of troops"); $troop_one = $result['$n[0]']; $troop_two = $result['$n[1]']; $troop_three = $result['$n[2]']; $troop_four = $result['$n[3]'];
  2. Hi kenrbnsn, Thnx this really helped me. Not only kenrbnsn thnx but all who responded thank you. Ryflex
  3. Hi all, I found out how to get to my info but it's kind of awkward... I have to use $n[1][name] to get my info out. Is there a way to get around the [name] part and just make it one-dimensional??? Thnx Ryflex
  4. Hi all, I got this far and got what is underneath but then how do I get the right values??? Thnx Ryflex $sql = "SELECT name FROM unittype WHERE type = 1"; $result = mysql_query($sql) or die("Could not find units"); while($data = mysql_fetch_assoc($result)) { $n[] = $data; } print_r($n); echo $n[0],$n[1],$n[2],$n[3]; Array ( [0] => Array ( [name] => gunner ) [1] => Array ( [name] => marine ) [2] => Array ( [name] => sniper ) [3] => Array ( [name] => special ops ) ) ArrayArrayArrayArray
  5. Hi Pikachu2000, I do understand that but is it possible in some other way to get the information in the way I mentioned??? Thnx Ryflex
  6. Hi harristweed, but my problem is not getting the information echoed but I need them in the variables $n1 till $n4 Thnx Ryflex
  7. Hi PFMaBiSmAd, If a mysql_fetch_array query only fetches one row what would a while loop do then??? Thnx Ryflex
  8. Hi all, This is a piece of code of my php page and what I need is that $n1 till $n4 is filled. Somehow only $n1 is filled. Can anyone tell me what I'm doing wrong here. Thnx Ryflex $sql = "SELECT name FROM unittype WHERE type = 1"; $result = mysql_fetch_array(mysql_query($sql)) or die("Could not find units"); $n1 = $result[0]; $n2 = $result[1]; $n3 = $result[2]; $n4 = $result[3]; echo "$n1 <BR> $n2 <BR> $n3 <BR> $n4";
  9. Hi, Thnx OOP for the reaction. I changed the $status to $status[] and made following as the exec page. Somehow it takes the last status number in the table and sets every row in the table with that number.... Anyone knows how to solve that??? Thnx Ryflex <?php require_once('auth.php'); require_once('config.php'); $global_dbh = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die("Could not connect to database"); mysql_select_db(DB_DATABASE, $global_dbh) or die("Could not select database"); foreach ($_POST['status'] AS $status) { $stat = $_POST['status']; $update = "UPDATE members SET status = '$stat'"; $update_result = mysql_query($update); echo "$status<BR>"; } ?>
  10. Hi zeroth, I'm doing the same as you but I just start building and when I encounter questions I ask on the forum. You just want everything pre-made and only make it look nice it seems. Just start coding yourself and let people help when needed. Ryflex
  11. Hi all, I'm currently working on an admin page and I'm trying to figure out how I can make an update query where all information will be updated. The code below is where I extract all the Users and their status from the database and now I when the statuses are updated in the text fields they need to be send to the database. Does anyone know how this could be done? Thnx Ryflex <?php require_once('auth.php'); require_once('config.php'); $global_dbh = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die("Could not connect to database"); mysql_select_db(DB_DATABASE, $global_dbh) or die("Could not select database"); $user_query = "SELECT * FROM members"; $user_result = mysql_query($user_query); ?> <form ID="gotoresource" NAME="gotoresource" METHOD="POST" ACTION="admin_exec.php"> <table width="500" border="1" align="center" cellpadding="2" cellspacing="0"> <tr> <td><b>ID</b></td> <td><b>User</b></td> <td><b>Status</b></td> </tr> <?php while($row = mysql_fetch_assoc($user_result)) { echo "<tr>"; echo "<td>"; echo $row['member_id']; echo "</td>"; echo "<td>"; echo $row['login']; echo "</td>"; ?> <td> <input type="text" name="status" value="<?php echo $row['status'];?>" /> </td> <?php echo "</tr>"; } ?> <input type="image" src="/images/button.gif" alt="Submit button"> </form> <html> <head> <title>AdminPage</title> <link href="loginmodule.css" rel="stylesheet" type="text/css" /> </head> <body> </body> </html>
  12. Hi Everyone, I'm trying to make an userlist where I have a button (or better a picture with a hyperlink) which if I click it I will be forwarded to a new page where the user name is send as a $_Post variable. The code below is what I have this far. In some way when I click the send button it always gives the last username in the table in the $_Post variable. Can anyone help me please. Thnx Ryflex <?php require_once('auth.php'); require_once('config.php'); $global_dbh = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die("Could not connect to database"); mysql_select_db(DB_DATABASE, $global_dbh) or die("Could not select database"); $user_query = "SELECT * FROM members"; $user_result = mysql_query($user_query); ?> <form ID="gotoresource" NAME="gotoresource" METHOD="POST" ACTION="resource_compose.php"> <table width="500" border="1" align="center" cellpadding="2" cellspacing="0"> <tr> <td><b>User</b></td> <td><b>Resource</b></td> </tr> <?php while($row = mysql_fetch_assoc($user_result)) { echo "<tr>"; echo "<td>"; echo $row['login']; $user = $row['login']; ?> <input name="User" type="hidden" maxlength="15" id="user" value="<?php echo $user; ?>"/> </td> <td> <input type="submit" name="Submit" value="Send" /> </td> <?php echo "</tr>"; } ?> <html> <head> <title>Userlist</title> <link href="loginmodule.css" rel="stylesheet" type="text/css" /> </head> <body> </body> </html>
  13. thnx all works perfectly now:D:D:D:D Ryflex
  14. Hi all, I have a database with some timestamps (in seconds) in it. Now I want to reverse it to normal readable time and date formats. Will someone tell me how please. Thnx Ryflex
  15. Ok found out through another forum. When using $_SESSION variables check if your links are staying on the same domain. www.example.com and example.com seems to be different. So make sure that when you start on example.com al your links stay on example.com/.... and not www.example.com/.... or backwards Ryflex
  16. ok my brother just checked and he still gets acces denied page.... any other possibility's??? Ryflex
  17. found one session start on one of the pages added comment slashes and let my brother try when home from work. thnx Ryflex
  18. Hi all, I checked it and it works perfectly until it goes to the frames page and then al frames go to the acces denied page..... before it goes through 3 pages an passes the session variable just fine... So now what??? I'm starting to lose my nerves here... Thnx Ryflex
  19. is anyone able to help??? Thnx Ryflex
  20. it has al pages do. it's just the stupid thing that it works on my computer fine but on others it has problems... Ryflex
  21. reg.php (set the $_SESSION variable) $qry2 = "SELECT * FROM members WHERE login = '$login' AND passwd = '".md5($_POST['password'])."'"; $result2 = mysql_query($qry2); $array2 = mysql_fetch_array($result2); $member_ID = $array2['member_id']; $_SESSION['SESS_MEMBER_ID'] = $member_ID; auth.php (checks the $_SESSION variable) <?php //Start session session_start(); //Check whether the session variable SESS_MEMBER_ID is present or not if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) { header("location: access-denied.php"); exit(); } ?> first line of every page after login or register <?php require_once('auth.php'); ?>
×
×
  • 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.