veronika Posted February 15, 2010 Share Posted February 15, 2010 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> Quote Link to comment Share on other sites More sharing options...
Stuie_b Posted February 15, 2010 Share Posted February 15, 2010 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 Quote Link to comment Share on other sites More sharing options...
Psycho Posted February 15, 2010 Share Posted February 15, 2010 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() Quote Link to comment Share on other sites More sharing options...
veronika Posted February 15, 2010 Author Share Posted February 15, 2010 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? Quote Link to comment Share on other sites More sharing options...
Deoctor Posted February 15, 2010 Share Posted February 15, 2010 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.. at least with the same name... u can use the query like this CREATE DATABASE IF NOT EXISTS homebudget; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.