Jump to content

ERROR on script


veronika

Recommended Posts

Okay, below is what I'm trying to accomplish.  I keep getting an error saying: Parse error: parse error in C:\wamp\www\solutionA.php on line 21.  That's the echo "$msg"  in the HTML portion.  I'm also trying to figure how to write in the tables in the php file.  If someone can help me out or point me to a good source I'd really apreciate it. 

 

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.

 

MY SCRIPT:

 

<?php

//variable to hold the query to issue, creates new database

$sql =  "CREATE database homebudget";

//connection information

$connection = mysql_connect ("localhost", "script", "9sj7En4")

or die (mysql_error());

//mysql_query()  funtion

$result= mysqlquery ($sql, $connection)

or die (mysql_erro());

//test value of $result

if ($result){

$msg="<P>Database HomeBudget has been created!</P>;

}

?>

//HTML portion

<HTML>

<HEAD>

<TITLE>HomeBudget Database</TITLE>

</HEAD>

<BODY>

<?php echo "$msg"; ?>    this is where i keep getting an error

</BODY>

</HTML>

 

Link to comment
https://forums.phpfreaks.com/topic/192097-error-on-script/
Share on other sites

You have number of errors in the proccess code,

 

Try the following

 

<?php
//variable to hold the query to issue, creates new database
$sql =  "CREATE database homebudget";
//connection information
$connection = mysql_connect("localhost", "script", "9sj7En4")or die (mysql_error());
//mysql_query()  funtion
$result= mysql_query($sql, $connection) or die (mysql_error());
//test value of $result
if ($result){
$msg="<P>Database HomeBudget has been created!</P>";
}
?>
//HTML portion
<HTML>
<HEAD>
<TITLE>HomeBudget Database</TITLE>
</HEAD>
<BODY>
<?php echo "$msg"; ?>    this is where i keep getting an error
</BODY>
</HTML>

 

Stuie

Link to comment
https://forums.phpfreaks.com/topic/192097-error-on-script/#findComment-1012401
Share on other sites

There are a LOT of errors in that bit of code.

 

First, off the reason for your current error is this line:

$msg="<P>Database HomeBudget has been created!</P>;

 

You need a double quote at the end of the line.

 

You also have this line

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

It should be mysql_query() and mysql_error()

 

Link to comment
https://forums.phpfreaks.com/topic/192097-error-on-script/#findComment-1012402
Share on other sites

I tried what you gave me and got :

Can't create database 'homebudget'; database exists

 

What does that mean? I'm still trying to understand the "PHP" language.  Does this have to do with the fact that my scrip doesn't have the script for the tables?

 

that means u already have a database with that name so u cannot create a new one..

:P at least with the same name...

u can use the query like this

 

CREATE DATABASE IF NOT EXISTS homebudget;

Link to comment
https://forums.phpfreaks.com/topic/192097-error-on-script/#findComment-1012450
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.