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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:09:55+00:00 2026-05-23T13:09:55+00:00

So I made this flash game and all appropriate variables are entered. If a

  • 0

So I made this flash game and all appropriate variables are entered. If a user is logged in, it SHOULD enter the variable $_SESSION[user] into the mysql database to store the user’s score. For some strange reason, it doesn’t do that. What makes it even stranger is that I can echo the $_SESSION[user] variable correctly, but when thrown into a mysql DB, it returns NULL (as 0). Here’s the code that does all the processing.

<?php 
session_start();
?>
<html>
<?php
include("../package.php");      //stuff for UI

echo $_SESSION[user];           //this works

if($_SESSION[user]){
mysql_query("INSERT INTO `DB`.`TABLE` (`user`,`type`,`game`,`score`) VALUES ('$_SESSION[user]', '$_POST[type]', '$_POST[g]', '$_POST[score]')");
?>
     //Congratulations message in HTML
<?php
}
else{
?>
   //Tells you to login (the 'else' statement to if($_SESSION[user])) also in HTML
<?php
}
?>

I don’t see anything wrong….

  • 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-23T13:09:56+00:00Added an answer on May 23, 2026 at 1:09 pm

    Change your logic to this, for debugging purposes:

    $sql = <<<EOL
    INSERT INTO `DB`.`TABLE` (`user`,`type`,`game`,`score`)
    VALUES ('$_SESSION[user]', '$_POST[type]', '$_POST[g]', '$_POST[score]')
    EOL;
    
    $result = mysql_query($sql) or die("query: $sql\n\n" . mysql_error());
    

    That’ll give you the full text of the generated query, as well as the exact error message MySQL produced. If the query succeeds, then things continue as normal. If there was an error, then you’ll be told why.

    Most likely the error is due to your mis-quoting of session values:

    PHP’s polite and will translate your $_SESSION[user] into $_SESSION['user'] (note the quotes). But when you do this from within a double-quoted string, all bets are off.

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

Sidebar

Related Questions

hey all, I have made a socket server in C# for a flash game
I have a sketch pad made in Flash AS3 like this one here: http://henryjones.us/articles/using-the-as3-jpeg-encoder
I made this function to verify a user's twitter credentials. Its running on two
I have made a website and put inside it a flash game. For people
I have a UK map made as a flash/swf movie. This map is embeded
I have made a simple animation in Flash and the i exported into a
I created a Flash room editor for an online game. The user is able
I have a game made by Flash CS5 ActionScript3. I want to create a
My designer has made a few animations for a flash game and I want
I've been working for a month on a flash game, which should be manageable

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.