Jump to content

Help with tables


veronika

Recommended Posts

Okay...I've been racking my brain for the past couple of hours and I can seem to figure this script out.  Can someone please help me get "unstuck" from where I'm at? :'(

 

This is my task:

Use the command-line interface to create a new user named "script" for your database. Grant that user all permissions on everything controlled by the DBMS.

  Create a database named "homebudget".

        Within that database, create two tables:

              The first table should be named "estimates". Give it three fields:

              VARCHAR of length 10 named "category"

              VARCHAR of length 30 named "description"

              INT named "budget"

          The second table should be named "expenses". Give it three fields:

            VARCHAR of length 10 named "category"

            DATE named "expenseDate"

              INT named "expenditure"

Create a script file named solutionA.php. Within that script, connect to your DBMS using the "script" identity. Select the "homebudget" database, then obtain a listing of the tables.

 

 

Here is my script:

<?

$sql=  "CREATE database  homebudget";

 

$connection  =  @mysql_connect  ("localhost",  "spike", "password")

or die (mysql_error());

 

$result =@mysqlquery($sql, $connetion)or die (mysql_erro());

 

mysql_select_db("homebudget", $connection)

 

$tbl= "CREATE TABLE estimate

(

Category varchar(10),

Description varchar(30),

Budget int

)";

 

I'm stuck trying to figure out the tables,  do I just start another variable  for the second talbe?

and I m not really understanding what needs to be in the .php file.    any help is greatly appreciated!!!

~nika

Link to comment
Share on other sites

hai

u need to start another variable for the second table as if u run the entire query like this

$sql="
DROP TABLE IF EXISTS `admin_user`;
CREATE TABLE `admin_user` (
  `admin_user` varchar(20) NOT NULL default '',
  `pwd` varchar(20) NOT NULL default '',
  `email_id` varchar(50) NOT NULL default '',
  `first_nm` varchar(30) NOT NULL default '',
  `last_nm` varchar(30) NOT NULL default '',
  PRIMARY KEY  (`admin_user`)
) ";

 

it will give you an error.. :o

 

so it is better u start a new string al together... :P

 

 

Link to comment
Share on other sites

your assignment clearly asks you to create the database and the tables with the database management tool, and write a php script to list the tables. It does not seem to be saying that you should create the database and the tables with the php script

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.