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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:05:40+00:00 2026-05-29T04:05:40+00:00

Is it true that after a user signs up, a sql table is create

  • 0

Is it true that after a user signs up, a sql table is create for him to store his posts ?
I make it similar in mysql after the man insert him into my page. The database is the same name with but the table name is made when he log in first time.

class Users
{
    var $username="root";
    var $password="pass";
    var $database="InsertIntoStackOverflow";
    var $table_name="";
    public function Users($username)
    {
       $table_name=$username."_tb";
       echo $table_name."<br/>";
       mysql_connect(localhost,$username, $password) or die("unable to connect to database ".mysql_error());
       echo $database."<br/>";
       mysql_selectdb($database) or die("unable to select db ".mysql_error());
       $query="CREATE TABLE ".$table_name." (id tinyint(4) NOT NULL AUTO_INCREMENT, title VARCHAR(128) NOT NULL, date_post VARCHAR(100), date_edit VARCHAR(100), post_content TEXT NOT NULL)";
       mysql_query($query) or die("Unable to create table. ".mysql_error());        
    }
}

But it display only table_name and an error, the database name not display. Error is NO DATABASE IS SELECTED/

EDIT

This class is call after he sign up
I also have a function postApost but when I do

ob_start();
session_start();
require("Users_DB.php");
$name=$_SESSION['user'];
echo 'Welcome '.$name;
$username=new UserDB($name);

there is no table created

  • 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-29T04:05:41+00:00Added an answer on May 29, 2026 at 4:05 am

    Two variables with same name $username. Use $this for accessing variable of class. Missing quote(“) with localhost – it must be string type parameter. and this code can’t create table on Database because you use AUTO_INCREMENT on your code but forgot to mention that as a PRIMARY KEY. I think the following code help you a lot.

    class Users
    {
        var $username="root";
        var $password="pass";
        var $database="InsertIntoStackOverflow";
        var $table_name="";
    
        function __construct($user_name)
        {
           $this->table_name=$user_name."_tb";
           echo $this->table_name."<br/>";
           mysql_connect("localhost",$this->username, $this->password) or die("unable to connect to database ".mysql_error());
           echo $this->database."<br/>";
           mysql_selectdb($this->database) or die("unable to select db ".mysql_error());
           $query="CREATE TABLE ".$this->table_name." (id tinyint(4) NOT NULL AUTO_INCREMENT, title VARCHAR(128) NOT NULL, date_post VARCHAR(100), date_edit VARCHAR(100), post_content TEXT NOT NULL, PRIMARY KEY (id))";
           mysql_query($query) or die("Unable to create table. ".mysql_error());        
        }
    }
    

    And you can use this class by the following way :

    $clsName = new Users('username');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DataGridView that has MultiSelect = true. After the user selects different
Is this true that Update SQL Query is slow because of Clustered index??????
I need to register an user and after that I would like to call
Is it true that the only way to handle default function arguments is through
Is it true that the smallest amount of memory that I can allocate in
Is it true that you cannot use COM Interop to expose COM properties? Everything
is it true that Rails depend on cookies? It seems that flash is a
Is it true that a service written in C# is unable to give visual
Is it true that any REST based API to upload videos will always require
Is it true that the syntax for (assign of variable value) is different than

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.