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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:59:24+00:00 2026-05-23T15:59:24+00:00

I have 2 files that are applicable to this question, myaccount.php and test5.php .

  • 0

I have 2 files that are applicable to this question, myaccount.php and test5.php.
test5 connects to MySQL database, and it is supposed to get the contents of one cell and print it out.

<?php

mysql_connect("mysql8.000webhost.com", "a5470121_tahahn5", "travis2") or
   die(mysql_error());
mysql_select_db("a5470121_rhs3") or die(mysql_error());


$result = mysql_query(
  "SELECT `user_name`,`Classperiod1` FROM users
   WHERE user_name ='" . $_SESSION['user_name'] . "'"
) or die(mysql_error());  


 $row = mysql_fetch_array( $result );
 echo   $row['user_name'];

?>

the second file myaccount.php is supposed to put the printout from the php file in html form

<h3> Your First ClassPeriod is<?php echo $row['Classperiod1']?></h3>  

I’ve tested this out and using both files with a specific username (ex.John, Andrew etc.) and it will print out the class period fine. When trying to use WHERE with a SESSION variable for some reason stops it from printing. It doesn’t even show any error messages.
Apologies for any mistakes in the code, or if this is a really stupid question. I’m nearly an absolute beginner where PHP and MySQL are concerned

  • 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-05-23T15:59:25+00:00Added an answer on May 23, 2026 at 3:59 pm

    You may want to remove your mysql details from your question!

    Are you starting a session using the session_start() function?
    http://php.net/manual/en/function.session-start.php

    I also don’t see where you’re setting $_SESSION['user_name']

    You might try echoing the mysql query you’ve constructed to see what it contains, this can help find out what’s wrong, I’d guess the session variable will be empty.

    For example:

    $sql = "SELECT user_name,Classperiod1 FROM users WHERE  user_name ='" . $_SESSION['user_name'] . "'";
    echo $sql;
    $result = mysql_query($sql) or die(mysql_error());  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two PHP files that I need to link. How can I link
I have several files that are in several different languages. I thought they were
I have some files that are uuencoded, and I need to decode them, using
I have some files that I'd like to delete the last newline if it
In almost all of my projects I have few files that are project wide
I have some source files that have comments written in Japanese. When I open
I have 2 wav files that I want to concatenate into one file with
I have two properties files that are not the same and I need to
I have potentially large files that need to be sorted by 1-n keys. Some
I have some html files that I want to convert to text. I have

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.