SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Zealot 容d席m L鷦i's Avatar
    Join Date
    Jan 2005
    Location
    Washington
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs down Chat script in php help...

    This is my first attempt at writing a chat script... So far everything works except then when you click shout it does not show the newest shout until you click refresh or click shout again. Can someone please help me with this. Here is my code:
    PHP Code:
    <?php

    session_start
    ();

    include(
    "gameconfig.php");


    $title "Chat";

    include(
    "style.css");

    if(!
    $email || !$password)
    {
        
    error("field");
    exit;
    }

    if(
    $playerinfo[password] != $password)
    {
        
    error("password");
    }
    else
    {
    include(
    "top.php");

    $time time();
    $select_chat =  mysql_query("SELECT username,text,tick FROM `chat` WHERE 1 AND $time - tick < 600 ORDER by `tick` asc");
    while(
    $nmon mysql_fetch_array($select_chat))
    {
     
    echo 
    "<center><table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
    <tr>
    <td><a href=/userinfo.php?name=
    $nmon[username] target=_blank>$nmon[username]</a>: $nmon[text]</td>
    </tr>
    </table></center>"
    ;
    }


    echo 
    "<center><table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
    <tr>
    <td><form name=shoutbox action=chat.php?action=shout method=post>
    <input type=\"text\" name=\"text\" size=\"50\" style=\"border: 1px solid #FFFFFF; background-color: black; color: white\"><br>
    <input type=\"submit\" value=\"Shout\" style=\"border: 1px solid #FFFFFF; background-color: black; color: white\"></center>"
    ;

    if(
    $action"shout"){
    if(!
    $username || !$text) {
    exit;
    }

    $insert_chat =  mysql_query("INSERT INTO `chat` (`username`, `text`, `tick`) VALUES ('$playerinfo[username]', '$text', '$time')");
    $insert_chat =  mysql_query("DELETE from `chat` where $time - tick > 800");

    }

    }


    ?>
    Thanks,
    David

  2. #2
    SitePoint Zealot 容d席m L鷦i's Avatar
    Join Date
    Jan 2005
    Location
    Washington
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    please people I really need help...

    I have been trying to figure this out for over a week I just want it out of my hair..

  3. #3
    SitePoint Member
    Join Date
    Jan 2005
    Location
    sc
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try changing
    Code:
    if($action= "shout")
    to
    Code:
    if($action == "shout")
    and see if that helps out

  4. #4
    SitePoint Zealot 容d席m L鷦i's Avatar
    Join Date
    Jan 2005
    Location
    Washington
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope same issue didn't work

  5. #5
    SitePoint Zealot 容d席m L鷦i's Avatar
    Join Date
    Jan 2005
    Location
    Washington
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    any other ideas??
    "'I earned political capital during this campaign and
    now I intend to spend it'-George Bush
    translation: if you thought i was a reckless moron
    these last four years, you aint seen nothing yet"-Lakai.com

  6. #6
    SitePoint Zealot 容d席m L鷦i's Avatar
    Join Date
    Jan 2005
    Location
    Washington
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anybody??
    "'I earned political capital during this campaign and
    now I intend to spend it'-George Bush
    translation: if you thought i was a reckless moron
    these last four years, you aint seen nothing yet"-Lakai.com

  7. #7
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    At My Desk!!
    Posts
    1,642
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cant you use some javascript to refresh the page automatiaclly??
    "Am I the only one doing ASP.NET in Delphi(Pascal)?"

  8. #8
    SitePoint Zealot 容d席m L鷦i's Avatar
    Join Date
    Jan 2005
    Location
    Washington
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I guess I could but I know absolutely no Javascript so I would need to get the code from someone else to do it.
    "'I earned political capital during this campaign and
    now I intend to spend it'-George Bush
    translation: if you thought i was a reckless moron
    these last four years, you aint seen nothing yet"-Lakai.com

  9. #9
    SEO Addict eli03's Avatar
    Join Date
    Aug 2004
    Location
    Pasig City Cainta, Philippines
    Posts
    68
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    create a separate page for this script, then put redirection to the index page of the shoutbox.
    PHP Code:
    if($action"shout"){ 
    if(!
    $username || !$text) { 
    exit; 


    $insert_chat =  mysql_query("INSERT INTO `chat` (`username`, `text`, `tick`) VALUES ('$playerinfo[username]', '$text', '$time')"); 
    $insert_chat =  mysql_query("DELETE from `chat` where $time - tick > 800"); 
    header("location: index page of shoutbox here ");



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •