Jump to content

Tandem

Members
  • Posts

    251
  • Joined

  • Last visited

    Never

Posts posted by Tandem

  1. | USERID | USERNAME      | PASSWORD                        | EMAIL
              | CASH      | LOCATION    | RANK    | GANG | POINTS | INBOXUNREAD |
    MESSAGESSENT | LIFESTATUS | GUN  | BULLETS | PROTECTION | HEALTH | SIGNUPDATE
            | USER_LEVEL | ACTIVATED | LAST_ONLINE        |

    It's a game about crime btw, just so you don't think i'm crazy or something :P
  2. I thought thats what you meant so i tried that aswell, now i'm getting all the results echo'd, but i'm getting the following error after them all:

    Warning: mysql_result() [function.mysql-result]: Unable to jump to row 4 on MySQL result index 7 in C:\Program Files\Apache Group\Apache2\htdocs\Find_player.php on line 104

    Not sure why :(
  3. I'm writing a search script for my game. It's supposed to search the database and echo the matches, but i'm having a problem with it.

    I'm getting this error after it displays the results:
    Warning: mysql_result() [function.mysql-result]: Unable to jump to row 4 on MySQL result index 7 in C:\Program....etc

    Can anyone tell me why?

    [code]<?php

    echo <<<HERE
    <div class="whitetext" align="center">\n
    <form method="GET" action="find_Player.php">\n
    Search:<input type="text" name="search" value=""><br />\n
    <input type="submit" name="submitsearch" value="Search!">
    HERE;

    $find_player = $_GET['search'];
    if (!empty($find_player)){
    $find_playerdb = mysql_query("SELECT USERNAME FROM USERS WHERE USERNAME LIKE '$find_player%'");
    $number_of_found_players = mysql_num_rows($find_playerdb);

    echo "<br><br><b><u>Players Found</u></b><br><br>";

    for ($i = 0; $i <= $number_of_found_players; $i++){

    $search_result = mysql_result($find_playerdb, $i);

    echo <<<HERE
    <divalign="center"><a href="profile.php?username=$search_result">$search_result</a></div>
    HERE;

    if ($number_of_found_players == 0){
    echo <<<HERE
    <divalign="center">*Your search returned 0 results.</div>
    HERE;
    }
    }
    }

    ?>[/code]

    Any help appreciated.

  4. SELECT * FROM EXAMPLE WHERE USER='T';

    I want the search to return every 'USER' that begins with a T. I'm pretty sure i have to add a character after the T but can't remember which, and the syntax for doing it.

    I read somewhere about how to do this a while back but forgot how, and my google searches are returning irrelevant results.

    Thanks for any help...
  5. Ok, i'm trying ot set up a news system on my site. The form that inputs the data into the database table works completely fine, it's just displaying the news atricles that gets me confused, and all the google searches i try come up with explanations that are in a different context and hard for me to understand how to change it for my needs.

    I want to display the news that is in the database on a page. How do i do this?

    I'm not sure what information i need to give for you to be able to help me better, so please somebody say and i'll post whatever is needed.

    Thanks,

    -Tandem
  6. Ok so i'm going to include at the top of each page, a script that records the time the page was loaded. Then i would class people who had loaded a page within a certain time range as Online and everyone else offline.

    Thankyou everyone for the help :)
  7. I'm still having some trouble understanding this.
    Lets say for examples sake, my table with the users information in it, that i want the online status to be stored in, hasn't got any fields relating to the whole online status issue in it.

    Could someone tell me what fields i would need to add, what code i would need to put and where, and explain to me what the important pieces of code do and how they operate?

    Sorry if thats kind of demanding, but i'm really quite stuck and would like to know what to do rather than aimless trial and error ;).

    I would be really grateful for any further help, and thanks in advance!
  8. How would you suggest that i record whether or not a member of my site is logged in?

    I was thinking, that i add a column to my table that holds the users info, called onlinestatus or something. When they log in, i use a query to update it to online..... but how would i update it to offline if the member exits the browser?

    Or is their a special method for doing this?

    Thanks in advance for any help

    -Tandem
  9. Sorry about that, here goes again, since the problem still isn't fixed.

    The problem is that when i click the delete link, nothing happens. The browser goes to the right place (i think)e.g /News.php?action=delete&id=0, but it just does nothing. Here's all the code:

    [code]<?php
    $data = file('news.txt');
    $data = array_reverse($data);
    foreach($data as $key => $element) {
        $element = trim($element);
        $pieces = explode("|", $element);
        echo <<<HERE
    <table align="center" cellspacing="0" cellpadding="2%" width="100%">
    <tr><td class="tablehead" cellpadding="0"> $pieces[3]
    HERE;
    if ($user_level_result > 1){
    echo <<<HERE
    <div align="right"><a href="$PHP_SELF?action=delete&id=$key">Delete</a>&nbsp;</div>
    HERE;
    }
    $pieces[2] = stripslashes($pieces[2]);
    echo <<<HERE
    </td></tr>
    <tr><td class="news" align="left">$pieces[2]</td></tr>
    <tr><td class="tablehead3" align="right"><b>Posted by   <a href="">$pieces[1]</a>   on   $pieces[0]  </b>&nbsp;
    </td></tr></table><br /><br />
    HERE;
    }
    if($action == "delete") {
    $data = file('news.txt');
    foreach ($data as $line) {
    $line = explode("|",$line);
    if ($line[0] != $_GET['id']) {
    $newfile[] = implode("|",$line);
    }
    }

    $open = fopen("news.txt", 'w');
    fwrite($open, implode("", $newfile));
    fclose($open);
    }

    ?>[/code]

    Any help to get it working is appreciated. And if there's something i've forgot to mention or something, just say and i'll post it.
  10. Ok, i've got a new problem. I'm trying to add the ability to delete news items to people of a certain user lever, eg. Admins or moderators.

    I used a tutorial, but i edited it to suit my needs. Here's the all the relevant code:
    Here's the code on the page i add the news from:
    [code]<table width="100%" height="100%" cellspacing="10%">
    <tr><td align="left">
    <table cellspacing="0">
    <tr><td class="tablehead" align="center">NEWS</td></tr>
    <tr><td class="main" align="center">
    <?php
    $poster_check = $_POST['poster'];
    $poster_check = mysql_query("SELECT USERNAME FROM USERS WHERE USERID='$_SESSION[userid]'");
    $poster = mysql_result($poster_check,0);

    $fp = fopen('news.txt','a');
    if(!$fp) {
    echo '<font face="verdana" size="1px" color="red">*Error Opening file!<br /></font>' . "\n";
        exit();
    }
    if (!empty($_POST['submit'])){
    $line = date("m.d.y") . "|" . $poster . "|" . $_POST['news'] . "|" . $_POST['newstitle'] . "\n";
    fwrite($fp, $line);
    }
         
    if(!fclose($fp)) {
    echo "Error closing file!";
    exit;
    }  [/code]

    And here's the code on the page which the news is displayed from and that i want to delete from:
    [code]<?php
    $data = file('news.txt');
    $data = array_reverse($data);
    foreach($data as $key => $element) {
        $element = trim($element);
        $pieces = explode("|", $element);
        echo <<<HERE
    <table align="center" cellspacing="0" cellpadding="2%" width="100%">
    <tr><td class="tablehead" cellpadding="0"> $pieces[3]
    HERE;
    if ($user_level_result > 1){
    echo <<<HERE
    <div align="right"><a href="$PHP_SELF?action=delete&id=$key">Delete</a>&nbsp;</div>
    HERE;
    }
    echo <<<HERE
    </td></tr>
    <tr><td class="news" align="left">$pieces[2]</td></tr>
    <tr><td class="tablehead3" align="right"><b>Posted by  <a href="">$pieces[1]</a>  on  $pieces[0]  </b>&nbsp;
    </td></tr></table><br /><br />
    HERE;
    }
    if($action == "delete") {
            $data = file('news.txt');
            //this next line will remove the single news item from the array
            array_splice($data,$id,1);
            $fp = fopen('news.txt','w');
            foreach($data as $element) {
                fwrite($fp, $element);
            }
            fclose($fp);   
            echo '<font face="verdana" size="1px" color="red">*Item Deleted<br /></font>' . "\n";   
    include 'news.php';
        }

    ?>[/code]

    I want anyone with a user_level over 1 to be able to click the delete link, and that news item to be deleted.

    Thanks in advance for any help

    -Tandem

  11. I thought the line of code was the only relevant piece....
    Here is everything that i think could possibly be relevant to this:
    [code]<?php
    if (empty($_POST['news'])){
    if (!empty($_POST['submit'])){
    echo '<font face="verdana" size="1px" color="red">*You did not enter any news into the form!<br /></font>' . "\n";
    exit;
    }
    }
    if(strstr($_POST['news'],"|")) {
    echo '<font face="verdana" size="1px" color="red">*News cannot contain the pipe symbol - " | "<br /></font>' . "\n";
    exit();       
    }
    ?>
    <table width="100%" height="100%" cellspacing="10%">
    <tr><td align="left">
    <table cellspacing="0">
    <tr><td class="tablehead" align="center">NEWS</td></tr>
    <tr><td class="main" align="center">
    <?php
    $poster_check = $_POST['poster'];
    $poster_check = mysql_query("SELECT USERNAME FROM USERS WHERE USERID='$_SESSION[userid]'");
    $poster = mysql_result($poster_check,0);

    $fp = fopen('news.txt','a');
    if(!$fp) {
    echo '<font face="verdana" size="1px" color="red">*Error Opening file!<br /></font>' . "\n";
        exit();
    }
    $line = date("m.d.y") . "|" . $poster . "|" . $_POST['news'] . "|" . $_POST['newstitle'] . "\n";
    fwrite($fp, $line);
         
    if(!fclose($fp)) {
    echo "Error closing file!";
    exit;


    ?>
    <form action="administrator_tools.php" method="POST" name="newsentry">
    <input type="hidden" name="poster" value="<?$poster?>"><br />
    News Title:<br /><input type="text" name="newstitle" value=""><br />
    The News:<br />
    <textarea name="news" cols="40" rows="5"></textarea><br />
    <input type="submit" name="submit" value="Post it!"><br />
    </form> 
    </td></tr>
    </table>
    </td></tr>
    </table>
    <br />
    </td></tr>
    </table>
    [/code]

    When i correctly submit the form this is the output to the text file: (The text file is empty before the submittance)
    [quote]07.18.06|Tandem||
    07.18.06|Tandem|This is the actual news story/update.|NEWS TITLE

    [/quote]
    The date, the name of poster, an empty space then a newline, then the date and poster again, then the news, then the news title, then another newline.


    What i want is:
    [quote]07.18.06|Tandem|This is the actual news story/update.|NEWS TITLE

    [/quote]
    The date, the poster, the news, the news title and then a newline.

    Sorry for not using the other topic, i'll try not to post twice about the same thing in future.
  12. *PLEASE SKIP STRAIGHT REPLY 7! - IGNORE THE ORIGINAL POST*

    I posted about this last night, but i seem to have run into more trouble with this.

    I have a news input section on the admin page i am making. The news i submit is saved to a text file, and then the news page reads the news from it. I'm having a problem with inputting the news and the details of it, into the text file.

    Here is my code for inputting into the text file:
    [code]$fp = fopen('news.txt','a');
    if(!$fp) {
    echo '<font face="verdana" size="1px" color="red">*Error Opening file!<br /></font>' . "\n";
        exit();
    }
    $line = date("m.d.y") . "|" . $poster . "|" . $_POST['news'] . "|" . $_POST['newstitle'] . "\n";
    fwrite($fp, $line);
    [/code]

    and here is what i get when i submit the news:
    [quote]07.18.06|Tandem||
    07.18.06|Tandem|This is the actual news story/update.|NEWS TITLE

    [/quote]

    What i want is:
    The date, the posters name, the news, the title, and then a new line. Like this:
    [quote]07.18.06|Tandem|This is the actual news story/update.|NEWS TITLE

    [/quote]

    But i just can't figure it out. Any help would be appreciated.

    Thanks in advance

    -Tandem
  13. Yeah, it appears it wasn't doing it twice, i just didn't have it so that my posts where on new lines, and that new features were being added as, making it look like they were posted twice. Thanks for the help people!
  14. [code]if (empty($_POST['news'])){
    if (!empty($_POST['submit'])){
    echo '<font face="verdana" size="1px" color="red">*You did not enter any news into the form!<br /></font>' . "\n";
    exit;
    }
    }
    if(strstr($_POST['news'],"|")) {
    echo '<font face="verdana" size="1px" color="red">*News cannot contain the pipe symbol - " | "<br /></font>' . "\n";
    exit();       
    }
    ?>
    <table width="100%" height="100%" cellspacing="10%">
    <tr><td align="left">
    <table cellspacing="0">
    <tr><td class="tablehead" align="center">NEWS</td></tr>
    <tr><td class="main" align="center">
    <?php
    $poster_check = $_POST['poster'];
    $poster_check = mysql_query("SELECT USERNAME FROM USERS WHERE USERID='$_SESSION[userid]'");
    $poster = mysql_result($poster_check,0);

    $fp = fopen('news.txt','a');
    if(!$fp) {
    echo '<font face="verdana" size="1px" color="red">*Error Opening file!<br /></font>' . "\n";
        exit();
    }
           
    $line = date("m.d.y") . "|" . $poster . "|" . $_POST['news'] . "|" . $newstitle;
    fwrite($fp, $line);
         
    if(!fclose($fp)) {
    echo "Error closing file!";
    exit;


    ?>
    [/code]

    This is eveything that corresponds to the process.
×
×
  • 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.