my code is messing up. help:

        if (mysql_query("CREATE DATABASE $dbname",$con))
        {
            echo "Database Created<br>";

            $dbase = $_POST["CallSign"]."char";

            mysql_select_db($dbase, $con);

            $sql = "SELECT * FROM $dbase";

            $result = mysql_query($sql);

            if ($result)

            {
                echo "CallSign Accepted<br>";

                mysql_select_db("my_db", $con);

                $sql="INSERT INTO users 
                (
                CallSign, 
                Email, 
                FirstName, 
                MiddleName, 
                LastName, 
                Gender, 
                BirthMonth, 
                BirthDay, 
                BirthYear, 
                Location, 
                Password,
                Origin,
                ) VALUES 
                (
                '$_POST[CallSign]',
                '$_POST[Email]',
                '$_POST[FirstName]',
                '$_POST[MiddleName]',
                '$_POST[LastName]',
                '$_POST[Gender]',
                '$_POST[BirthMonth]',
                '$_POST[BirthDay]',
                '$_POST[BirthYear]',
                '$_POST[Location]',
                '$_POST[Password1]',
                Now()
                )";

                if (mysql_query($sql,$con))
                {
                    echo "Values Posted<br>";

                    $dbase = $_POST["CallSign"]."char";

                    mysql_select_db($dbase, $con);

                    $sql = "CREATE TABLE chars 
                    (
                    charID int NOT NULL AUTO_INCREMENT,
                    PRIMARY KEY(charID),
                    CharName varchar(15),
                    CharPub TEXT,
                    CharPriv TEXT,
                    CharGame int DEFAULT '0', 
                    CharBorn TIMESTAMP DEFAULT NOW()
                    )";

                    if (!mysql_query($sql,$con))
                    {
                        die('Error: ' . mysql_error());
                    }
                    else
                    {
                        echo "Account Created";
                        echo "<p><a href='index.php'>Return to Login</a>";
                    }

                }
                else
                {
                    $dbase = $_POST["CallSign"]."char";

                    mysql_select_db($dbase, $con);

                    $sql = "CREATE TABLE chars 
                    (
                    charID int NOT NULL AUTO_INCREMENT,
                    PRIMARY KEY(charID),
                    CharName varchar(15),
                    CharPub TEXT,
                    CharPriv TEXT,
                    CharGame int DEFAULT '0', 
                    CharBorn TIMESTAMP DEFAULT NOW()
                    )";

                    if (!mysql_query($sql,$con))
                    {
                        die('Error: ' . mysql_error());
                    }
                    else
                    {
                        echo "Callsign Reguested<br>Database Created<br>Tables Organized<br>Cajun Style<p>";
                        echo "Account Created";
                        echo "<p><a href='index.php'>Return to Login</a>";
                    }

What kind of error you get?

is isnt inserting into the designated table

At line 9 I see this string:

$sql = "SELECT * FROM $dbase";

so you have a table with the same name of the database? I ask this because it seems your script expects a true condition from $result variable in the IF statement at line 13, so I suggest you to change line 11 with this:

$result = mysql_query($sql) or die(mysql_error());

and check if you get an error or false.

im getting an unexpecting end of file error now

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.