Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8727007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:21:36+00:00 2026-06-13T08:21:36+00:00

I am working on my chat script, however I only get every second sql

  • 0

I am working on my chat script, however I only get every second sql entry on the page

I have posted my codes below

Add.php code:

<?php
mysql_connect( 'localhost:/tmp/mysql.sock', 'xxxxx', 'xxxxx' );
mysql_select_db( 'ios' );
mysql_query( "INSERT INTO chatitems VALUES ( null, null, '".mysql_real_escape_string( $_GET['user'] )."', '".mysql_real_escape_string( $_GET['message'] ). "')" );
header("Location: messages.php");
?>

messages.php code:

<?php
$host="localhost:/tmp/mysql.sock";
$username="xxxxx";
$password="xxxxx";
$db_name="ios";
$tbl_name="chatitems";

mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");


$sql="SELECT * FROM $tbl_name ORDER BY id DESC";
$result=mysql_query($sql);

$rows=mysql_fetch_array($result);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="index,follow" name="robots" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link href="pics/homescreen.gif" rel="apple-touch-icon" />
<meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport" />
<link href="css/style.css" rel="stylesheet" media="screen" type="text/css" />
<script src="javascript/functions.js" type="text/javascript"></script>
<title>VT Chat
</title>
<link href="pics/startup.png" rel="apple-touch-startup-image" />
</head>
<body>
<p>
<div id="content">
<?php
while($rows=mysql_fetch_array($result)){ 
?>
<ul class="pageitem">
<li class="textbox"><span class="header"><? echo $rows['user']; ?></span><p>
<? echo $rows['message']; ?></p></li>
<li class="pageitem"><span class="header"><? echo $rows['added']; ?></span></li>
</ul><p>
<?
}
mysql_close();
?>  
</div>
</body>
</html>

So I simply just need to it show EVERY SQL entry but still the newest at the top

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:21:36+00:00Added an answer on June 13, 2026 at 8:21 am

    You have this line twice:

    $rows=mysql_fetch_array($result);
    

    Get rid of the first one and just use:

    while($row = mysql_fetch_array($result)){
        echo $row['message']
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on this script that have emoticons work on the Campfire Chat. I
I got the chat example working from Atmosphere, and now I want to get
I am working on pjsip for voice chat on iPhone. The steps I have
I have been working on on an AJAX chat application using php, mysql. It's
I am working on a Python chat script, the client looks like this: import
I'm writing a script to add extra smileys to the Gmail chat. Its working
I'm trying to implement long polling in a php chat script, however the long
I have been working on a chat application and I need some suggestions to
I am working on a Chat application. I need to verify user that only
I am working on a chat aaplication.In which i have to chat window through

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.