www.webdeveloper.com
Results 1 to 8 of 8

Thread: [RESOLVED] MySQL data not displaying

  1. #1
    Join Date
    Oct 2013
    Posts
    12

    resolved [RESOLVED] MySQL data not displaying

    I really can't get this one, and it doesn't seem as obvious.

    So, I'm trying to make a chat for my site, but first off, it isn't displaying the data. Second, here's a screenshot of the problem.
    http://puu.sh/53ddT.png

    Here's the code.
    PHP Code:
    <?php
    include_once('../include/session.php');
    mysql_query("SELECT * FROM chat ORDER BY id DESC LIMIT 90'");
    ?>
    <font color="<? 
    mysql_connect
    ("*****""*****""*****") or
    die(
    "No se pudo conectar: " mysql_error());
    mysql_select_db("ni235658_1sql2");
    $resultado mysql_query("SELECT chatcolor FROM users WHERE username='".$rows[name]."'");
    while (
    $fila mysql_fetch_array($resultadoMYSQL_BOTH)) {
    printf ("%s"smiles(BBcode($fila[chatcolor])));} ?>">
    <?php echo $rows['name']; ?>:</font> <?php echo smiles($rows[message]) ?><br>
    Also, it doesn't notice that I ended the "font color" html code. Instead, before AJAX refreshing, says ">: in blue, then turns to just a :.

    Here is my table.
    http://puu.sh/53dxg.png

    Proof that it does in fact have rows.
    http://puu.sh/53dIy.png

    So it IS inserting, just not displaying. Please help. Thanks.
    Last edited by NogDog; 10-30-2013 at 07:36 AM. Reason: removed db connection credentials

  2. #2
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    724
    I don't see where you are storing the results of the first query. I also don't understand that font color thing. Not at all.

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,334
    My suggestion would be to reorganize your code. Take care of all the database connection and queries first, assigning results to variables (whether scalar or array). Right now it looks like you try to do your first query before you connect to the database?

    Then do your output, echoing the applicable variables where needed.

    Also, always use the full <?php tag, as <? is not supported in all environments/configurations.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  4. #4
    Join Date
    Oct 2013
    Posts
    12
    Quote Originally Posted by NogDog View Post
    My suggestion would be to reorganize your code. Take care of all the database connection and queries first, assigning results to variables (whether scalar or array). Right now it looks like you try to do your first query before you connect to the database?

    Then do your output, echoing the applicable variables where needed.

    Also, always use the full <?php tag, as <? is not supported in all environments/configurations.
    OH, WHOA. I accidentally posted the database info! As a moderator, I can guess you can edit it. Can you please remove that?
    Also, the MySQL doesn't even need to be connected because session.php connects everything.

  5. #5
    Join Date
    Oct 2013
    Location
    kurdistan
    Posts
    4
    I haven't understand any thing in font color but make the code like this:

    PHP Code:

    <?php
    include_once('../include/session.php');

    ?>

    <?php

    mysql_connect
    ("*****""*****""*****") or
    die(
    "No se pudo conectar: " mysql_error());
    mysql_select_db("ni235658_1sql2");

    $resultado mysql_query("SELECT * FROM chat ORDER BY id DESC LIMIT 90'");

    while (
    $row mysql_fetch_array($resultado)) {

    echo 
    '<font color="blue">'.$rows['name'].' : </font>';

    echo 
    $rows['message'].'<br>';

    }

     
    ?>

    may be this will work.

    Sorry I have write this from mobile for that I am sorry for any wrong.

  6. #6
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    724
    This code sample is obviously full of mistakes. When you get home and actually try it out and debug it, then ask for help.

  7. #7
    Join Date
    Oct 2013
    Posts
    12
    The "font color" code is to echo the user's chat color username. It connects to the user table and selects that and then returns it.

  8. #8
    Join Date
    Oct 2013
    Posts
    12
    Well, got it working. It displaying >: was because of a really bad AJAX system, and has been replaced. Also, I had been echoing much stuff wrong.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles