im creating a simple website and database for a project with minimal functionality. All i'm supposed to do is create a website that communicates with a database. i chose to do that project with php, ajax and mysql in xamp. Now i've decided to work on the database first, i want it to be portable where i can just put the completed code in folder on a flash drive and go to school with it. where i'll jus be able to copy it to the htdocs folder in the xamp and it will automatically create the database and run all the queries. For some reason, no matter what i try it won't show up in the phpmyadmin databases section. I desperately need help, i wanna kno if my idea is possible and how can i go about it.. here's my code.. thanks much to any help, will be greatly appreciated..
the config.php
<?php$db_name="dscdb";$db_user="root";$db_password="";$db_server="localhost";?>
heres my connection mysqlconnection.php
<?phpinclude($_SERVER['DOCUMENT_ROOT'].'/FinalProject/config.php');$con=mysql_connect($db_server,$db_user,$db_password) or die("Connection Failure: ".mysql_error());mysql_select_db($db_name,$con); ?>
and heres my database and query creation.. setup.php
<?phpinclude($_SERVER['DOCUMENT_ROOT'].'/Finalproj/config.php');{$con = mysql_connect($db_server,$db_user,$db_password); // database connect//Database creation mysql_query("CREATE DATABASE IF NOT EXISTS $db_name" $con) or die("creating database fails".mysql_error()); USE $db_name; mysql_select_db($db_name) or die(mysql_error()); //Students Table creation mysql_query("CREATE Table IF NOT EXISTS 'Students'('StudID' varchar NOT NULL (15) , primary key (StudentID), 'FirstName' varchar(15) NOT NULL, 'LastName' varchar (15) NOT NULL, 'BirthDate' DATE NOT NULL, 'Address' varchar(30) NOT NULL, 'MajorTitle' Foreign key (MajorTitle) References Majors(MajorTitle) NOT NULL, 'Username' varchar(15) NOT NULL, 'Password' varchar(8) NOT NULL)") or die("Failed to create Table".mysql_error()); mysql_query($con,"INSERT into Students(StudID, FirstName, LastName, BirthDate, Address, MajorTitle, Username, Password) values ('123', 'lee', 'daniel', '1990-01-08', 'Bioche', 'Computer Science', 'lee', 'daniel')"); mysql_query($con,"INSERT into Students(StudID, FirstName, LastName, BirthDate, Address, MajorTitle, Username, Password) values ('456', 'danphil', 'daniel', '1992-06-25', 'Bioche', 'Electronics', 'danphil', 'daniel')"); mysql_query($con,"INSERT into Students(StudID, FirstName, LastName, BirthDate, Address, MajorTitle, Username, Password) values ('789', 'eber', 'raver', '1988-03-28', 'Colihaut', 'Physics', 'eber', 'raver')") //$hashedpassword=sha1("password");// Instructor Table creation mysql_query("CREATE Table IF NOT EXISTS 'Instructors'('InstrucID' varchar NOT NULL (15), primary key (InstrucID), 'FirstName' varchar (15) NOT NULL, 'LastName' varchar (15) NOT NULL, 'Address' varchar(30) NOT NULL, 'Username' varchar (15) NOT NULL, 'Password' varchar(8) NOT NULL) ") or die("Failed to create Table".mysql_error()); mysql_query($con,"INSERT into Instructors(InstrucID, FirstName, LastName, Address, Username, Password) values ('abc', 'larry', 'thomas', '1982-09-14', 'Goodwill', 'larry', 'thomas')"); mysql_query($con,"INSERT into Instructors(InstrucID, FirstName, LastName, Address, Username, Password) values ('def', 'james', 'victor', '1986-09-06', 'Grandbay', 'james', 'victor')"); mysql_query($con,"INSERT into Instructors(InstrucID, FirstName, LastName, Address, Username, Password) values ('ghi', 'barnaby', 'jack', '1977-11-23', 'ireland', 'barnaby', 'jack')");//Registrar Table creation mysql_query("CREATE Table IF NOT EXISTS 'Registrars' ('RegID' varchar NOT NULL (15), primary key(RegID), LastName varchar (15) NOT NULL, Username varchar (15) NOT NULL, Password varchar(15) NOT NULL) ") or die("Failed to create Table".mysql_error()); mysql_query($con,"INSERT into Registrars(RegID, LastName, Username, Password) values ('abc123', 'jones', 'jones', 'jones')"); //Majors table creation mysql_query("CREATE Table IF NOT EXISTS 'Majors' ('MajorType' varchar NOT NULL (15), primary key (MajorID), 'MajorTitle' varchar (20) NOT NULL)") or die("Failed to create Table".mysql_error()); mysql_query($con,"INSERT into Majors('MajorType', 'MajorTitle') values ('FAS', 'Computer Science')"); mysql_query($con,"INSERT into Majors('MajorType', 'MajorTitle') values ('FAS', 'Physics')"); mysql_query($con,"INSERT into Majors('MajorType', 'MajorTitle') values ('FAAT', 'Electronics')"); echo "<script>alert('The webApp has been installed successfully')</script> "; mysql_close();}}?>