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 8878259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:40:19+00:00 2026-06-14T19:40:19+00:00

I’ve created a table (notebook) where I keep user’s text. The table is like

  • 0

I’ve created a table (notebook) where I keep user’s text. The table is like this one:

+------+------------+-------+------+--------+------------------------+
|  id  |  Username  | title | html | public |  create_date           |
|--------------------------------------------------------------------|
|   1  | sorge13248 | Test  | ...  |  n     |2012-11-24 9:00:00      |
+------+------------+-------+------+--------+------------------------+

id = INT(25) A_I NOT NULL
Username = VARCHAR(65) NOT NULL
title = VARCHAR(26) NOT NULL
html = LONGTEXT NOT NULL
public = VARCHAR(11) NOT NULL
create_date = TIMESTAMP CURRENT_TIMESTAMP NOT NULL

So, I’ve tried to use this code to list all notebook’s record for a user:

$link = mysql_connect("localhost", "mysql_user", "password");
mysql_select_db("notebook", $link);

$result = mysql_query("SELECT * FROM notebook WHERE Username = '"$username."'", $link);

if(0 == mysql_num_rows($result)) {
    echo 'No notebook was created for this user';
}
else { 
    while(row = mysql_fetch_array($result)) {
       // do whatever you want with the data here
    }
}

The code has been taken from: How to list rows for a query or display 'no records' using a single query and I’ve edited it for use it with my table.

Now, I’m confused, what I must write in “// do whatever you want with the data here” string to list the records?

EDIT: Now, I have this code, but Chrome says “HTTP 500 Error, Internal Server Error”:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Notebook</title>
</head>

<body>
<h1>Notebook</h1><br/>
<?=
$link = mysql_connect("localhost", "database_username", "password");
mysql_select_db("database_name", $link);

$result = mysql_query("SELECT * FROM notebook", $link);

// If if result set contains rows
if(0 == mysql_num_rows($result)) {
    echo 'No notebook was created for this user';
}
else { 
    while(row = mysql_fetch_array($result)) {
   printf( '%d: &quot;%s&quot; by %s<br />', $row['id'], 
                 htmlspecialchars($row['title']), 
                 htmlspecialchars($row['Username']) );
}
}
?>
</body>

</html>

Where is the error? The MySQL credentials are provide correctly…

  • 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-14T19:40:20+00:00Added an answer on June 14, 2026 at 7:40 pm

    Form HTML with whatever you want to display, so your while loop would look like, i.e.:

    while(row = mysql_fetch_array($result)) {
       printf( '%d: &quot;%s&quot; by %s<br />', $row['id'], 
                     htmlspecialchars($row['title']), 
                     htmlspecialchars($row['Username']) );
    }
    

    which would list all items, like

    1: "Test" by sorge13248
    

    PS: you should always use the same naming convention to avoid problems. in your DB all columns are lowercased, except Username).

    • 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
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I am reading a book about Javascript and jQuery and using one of the

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.