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

  • SEARCH
  • Home
  • 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 8218619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:51:43+00:00 2026-06-07T12:51:43+00:00

I’m relatively new to this, so sorry if I’m posting in the wrong place.

  • 0

I’m relatively new to this, so sorry if I’m posting in the wrong place.
I’ve got a table in my database which holds 4 things – id, time put in and user and message (for a basic chat-room style thing).
I’m trying to call these using a PHP page. But my page just gets returned blank when I put an argument in the address bar. I’m trying to call it so that only lines with a certain user in the user column get shown. My code is below – can anybody see what I am doing wrong?
The URL of the file is http://freedom-apps.co.uk/chat/messages.php. You see a load of entries – at the start, there is u m u m u m. U represents the user entered, m is the message. So I tried:
http://freedom-apps.co.uk/chat/messages.php?user=u
which returns an error. Any ideas?
My code is:

<?php
header( 'Content-type: text/xml' );
mysql_connect('localhost:/var/lib/mysql/mysql.sock', 
              'freedom_ASAPPS', '********');
mysql_select_db( 'freedom_chat_alpha' );
if ( $_REQUEST['user'] ) {
    $user = mysql_escape_string($_REQUEST['user']);
    $result = mysql_query('SELECT * FROM chatitems WHERE user = '$user' 
              ORDER BY added LIMIT 50');
} else {
    $result = mysql_query('SELECT * FROM chatitems ORDER BY added LIMIT 50');    
}
?>
<chat>
<?php
while ($row = mysql_fetch_assoc($result)) {
?>
<message added="<?php echo( $row['added'] ) ?>" 
    id="<?php echo( $row['id'] ) ?>">
    <user><?php echo( htmlentities( $row['user'] ) ) ?></user>
    <text><?php echo( htmlentities( $row['message'] ) ) ?></text>
</message>
<?php
}
var_dump($result);
mysql_free_result($result);
?>
</chat>

I believe it is something wrong with line 6 and 7, or in the way I call the php page with the argument (see above). I’ve being referring to the book I have used to learn this stuff, and still can’t figure it out (Learning PHP, MySQL, and JavaScript: A Step-by-Step Guide to Creating Dynamic Websites).

Thanks,
Sam

  • 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-07T12:51:44+00:00Added an answer on June 7, 2026 at 12:51 pm
    $result = mysql_query('SELECT * FROM chatitems WHERE user = '$user' ORDER BY added LIMIT 50');
    

    This is a syntax error – you’re missing the string concatenation operators:

    $result = mysql_query('SELECT * FROM chatitems WHERE user = ' . $user . ' ORDER BY added LIMIT 50');
                                                                ^^^------^^^^--- here
    

    Alternatively, use double-quoted strings:

    $result = mysql_query("SELECT * FROM chatitems WHERE user = '$user' ORDER BY added LIMIT 50");
    

    Getting a blank page suggests you’ve got display_errors turned off in php.ini. You should turn that on while debugging/developing. You’re just shooting yourself in the foot hiding the very messages that would have told you what the problem was.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.
I want use html5's new tag to play a wav file (currently only supported

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.