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
https://forums.phpfreaks.com/topic/192103-help-with-tables/
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
https://forums.phpfreaks.com/topic/192103-help-with-tables/#findComment-1012429
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
https://forums.phpfreaks.com/topic/192103-help-with-tables/#findComment-1012464
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.