Jump to content

veronika

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

veronika's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Im not understading the last 2 sections of the assignment: -Modify the script so that it retrieves the values entered by the visitor -Modify the SELECT statement created within the script so that it includes a WHERE clause which will test to make sure that the category column is equal to the value entered by the visitor I ccreated the HTML which containes and input box for the customers to enter a expense. If Im understanding right the .php is supposed to pick up all the entered expenses from the .html and diplay them in a table. Im not understanding the last two steps....PLEASE HELP!
  2. THANKS that worked...I appreciate the help ~nika
  3. THANKS Dennis 1986... I am very new to PHP so Im not quite understanding a lot of it. But anyways I am now getting the follwing error: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\solution09.php on line 15 line 15 has: while ($row= mysql_fetch_array ($result)) What does that error mean?
  4. Hey guys, can someone please help me. I have the following assignments: Assignment #9: Report Generation In this assignment you will create a pair of Web documents - a form and a script - which will display a list of expenditures from our homebudget database. Submission will only require one page - the script. Name your script solution09.php. Within the script, construct a SELECT statement which will query the "expenses" table for all of the family's purchases. Process the resulting recordset with a while loop which will create a separate line for each expense. (NOTE: You can use line-break tags.) On each line, display the category, date, and amount of the expense. (NOTE: How would you modify the table, now that you are beginning to use it? Would you add a "payee" column? How about an "expenseID" column? Discuss these possibilities on the boards, and relate your recommended additions back to the concept of "scope creep", which we have mentioned a few times.) On the HTML form, provide the visitor with an input box he/she may use to enter an expense category. Name the form solution09.html Modify your script so that it retrieves the value entered by the visitor. Modify the SELECT statement created within your script so that it includes a WHERE clause which will test to make sure that the category column is equal to the value entered by the visitor. And I have this script: I keep getting an error in line 18 but i don't know whet the problem is. I know that script is not completer but im trying to understand what this error is and get it out the way... any help is greatly appreciated: <?php $connection=mysql_connect ("localhost", "spike", "9sj7En4"); if (!$connection) { die ('Could not Connect: '. mysql_error()); } mysql_select_db ("My_DB", $connection); $result = mysql_query ("SELECT * FROM Expenses"); echo "<table border='3'> <tr> <th>Category</th> <th>Date</th> <th>Dollar Amount</th> </tr>"; while ($row=mysql_fetch_array ($result)) { echo "<tr>" echo "<td>" .$row ['Category'] ."</td>" ; echo "<td>" .$row ['Date'] ." </td>"; echo "<td>" .$row ['Dollar Amount'] . " </td>"; echo "</tr>"; } echo "</table>"; mysql_close ($connection); ?> <HTML> <HEAD> <TITLE>Solution09</TITLE> </HEAD> <BODY> <h1>Report Generation</h1> </BODY> </HEAD> </HTML>
  5. That line is all in one...for some reason when i post it here it separated. Now, I named the file solution08 .php Do you think the part has something to do with it? It won't let me post the error...sorry
  6. yes...they're both saved under the document root of my web server
  7. When I submit my .html form to talk to my .php i get awebpage not found error message. Can someone please look at the script and let me know what is missing/wrong. I've checked like over and over again and I can't seem to get it. HTML: <HTML> <HEAD> <TITLE>Assignment: Lab #8</TITLE> </HEAD> <BODY> <H1>Records added to Estimates</H1> <FORM METHOD="POST" ACTION="solution08 .php"> <TABLE CELLSPACING = 8 CELLPADDING = 10 > <TR> <TD VALIGN = TOP> <P><strong>BUDGET:</strong><BR> <INPUT TYPE = "text" NAME = "budget" SIZE=15 MAXLENGTH=15></P> <TD VALIGN = TOP> <P><STRONG>CATEGORY (Select One):</STRONG><BR> <select> <option>Credit Card</option> <option>Check</option> <option>Cash</option> </select> </P> </TD> </TR> <TR> <TD VALIGN = TOP COLSPAN = 2 ALIGN = LEFT> <P><Strong>DESCRIPTION</strong>:<BR> <TEXTAREA NAME = "description" COLS=35 ROWS=5 WRAP=virtual></TEXTAREA></P> <P><INPUT TYPE = "submit" NAME = "submit" VALUE ="Add Record"></P> </TD> </TR> </TABLE> </FORM> </BODY> </HTML> .PHP: <? if ((!$_POST['budget']) || (!$_POST['category']) || (!$_POST['description'])) { header( "Location: solution08 .html"); exit; } $dbhost = 'localhost'; $dbuser = 'spike'; $dbpwd = '9sj7En4'; $conn=mysql_connect($dbhost,$dbuser,$dbpws) or die (mysql_error()); $dbname = 'homebudget'; $table_name = 'estimates'; mysql_select_db($dbname); $budget = mysql_escape_string (!$_POST['budget']); $category = mysql_escape_string (!$_POST['category']); $description = mysql_escape_string (!$_POST['description']); $sql = "INSERT INTO $table_name (budget, category, description) VALUES ('$budget', '$category', '$description')"; $result = mysql_query($sql, $connection) or die(mysql_error()); ?> <HTML> <HEAD> <TITLE>Assignment: Lab #8</TITLE> </HEAD> <BODY> <H1>Added Record <? echo "$table_name"; ?></H1> <TABLE CELLSPACING=5 CELLPADDING=5> <TR> <TD VALIGN=TOP> <P><STRONG>Budget:</STRONG><BR> <? echo "$budget";?></P> <P><STRONG>Category:</STRONG><BR> <? echo "$category"; ?></P> </TD> <TR> <TD VALIGN=TOP COLSPAN=2 ALIGN=CENTER> <P><STRONG>Description:</STRONG><BR> <? echo stripslashes("$description"); ?></P> <P><a href = "solution08 .html">Add Another</a></P> </TD> </TR> </TABLE> </BODY> </HTML>
  8. Not offended here!!! I know this is wrong and Im just trying to get some guidance and trying to understand what work and why?THANKS for the help!!! <?php $sql="CREATE database hombudget"; $connection= mysql_connect ("localhost","spike", "9sj7En4") or die (mysql_error()); $result=mysqlquery ($sql, $connection) or die (mysql_error()); mysql_select_db("homebudget", $connection) $tbl= "CREATE TABLE estimate ( Category varchar (10), Description varchar (30), Budget int )";// i don't know what you mean by a primary key? what it that? $slq = " DROP DATABASE IF EXIST 'homebudget' CREATE TABLE 'expenses' ( Category varchar (10), espenseData DATE, expenditure INT )";//do I need to remover the ; what is the purpose of that? just wondering because my book examples have them $result=mysql_query ($sql, $connection)//isn't this the $result variable? or die (mysql_error()); if ($results) { $msg = "<P>Database Homebudget has been created </P>"; } ?> <HTML> <HEAD> <TITLE>Homebudget Database</TITLE> </HEAD> <BODY> <?php echo $msg; ?> </BODY> </HTML>
  9. Okay I KNOW that there is something wrong with this script. I ran it to tested and got nothing on the display page. Can someone please take a look at it and point out errors? I'm still trying to get this whole PHP stuff so please explain it as basic as possible. <?php $sql="CREATE database hombudget"; $connection= @mysql_connect ("localhost","spike", "9sj7En4") or die (mysql_error()); $result=@mysqlquery ($sql, $connection) or die (mysql_error()); mysql_select_db("homebudget", $connection) $tbl= "CREATE TABLE 'estimate' ( Category varchar (10), Description varchar (30), Budget int )"; $slq = " DROP DATABASE IF EXIST 'homebudget' CREATE TABLE 'expenses' ( Category varchar (10), espenseData DATE, expenditure INT )"; $result=mysql_query (4sql, $connection) or die (mysql_error()); if ($results) { $msg = "</P>Database Homebudgethas been created </P>"; } ?> <HTML> <HEAD> <TITLE>Homebudget Database</TITLE> </HEAD> <BODY> <?php echo "$msg"; ?> </BODY> </HTML> This is what my im trying to accomplish: Grant spike user all permissions on everything controlled by the DBMS. • Create a database named "homebudget". • Within that database, create two tables: o 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" o 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.
  10. 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
  11. 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?
  12. 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>
  13. Okay...as I posted last week I'm new with the whole PHP thing. I need help wuth the following, any help is greatly appreciated. I will be loading what I script for review here: • 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: o 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" o 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 solution07.php. Within that script, connect to your DBMS using the "script" identity. Select the "homebudget" database, then obtain a listing of the tables. • Use the file-creation techniques we learned in previous classes to save the results of your queries into a file named solutionA.txt. • Submit both solutionA.php and solutionA.txt.
  14. wildteen88---THANK YOU SOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO MUCH, I feel like an idiot!!! thanks for the help. ~nika
  15. Ok...so I installed this WAMP server to do my PHP class. I am now having trouble with it. The book gives me step by step on how to install MySQL, Apache, and PHP but the problem is that I was told to just download WAMP and not seperatly. Now my assignment is requesting me to start MySQL Monitor from the command line and I cannot get it to work. Can someone offer some help on how to open this MySQL Monitor?
×
×
  • 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.