Why am I getting this error using 000webhost , but I do not get this error running XAMPP?
Warning: Cannot modify header information -
headers already sent by (output started at
/storage/ssd2/006/14881006/public_html/test/index.php:1) in
/storage/ssd2/006/14881006/public_html/test/index.php
on line 8
Code is below.
********************************************************************************************************************
<!DOCTYPE html>
<?php
//Determine if the submit button has been clicked
to set the cookie name and value
if (isset($_POST['name'])){
$cookie_name =
$_POST['name'];
$cookie_value =
$_POST['value'];
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/");
// 86400 = 1 day
} else {
$cookie_name = NULL;
$cookie_value = NULL;
}
?>
<html>
<body>
<!-- Form to get cookie name and
value -->
<form action="index.php"
method="post">
<p>Cookie
name: <input type="text" name="name" /></p>
<p>Cookie
value: <input type="text" name="value" /></p>
<br>
<p><input type="submit" name="Submit"/></p>
</form>
<?php
//Display
cookie name and value
if(!isset($_COOKIE[$cookie_name])) {
echo "Cookie
named '" .$cookie_name. "' is not set!";
} else {
echo "Cookie '"
.$cookie_name. "' is set!<br>";
echo "Value is:
" .$_COOKIE[$cookie_name];
}
?>
<p><strong>Note:</strong> You might have to
reload the page to see the value of the cookie.</p>
</body>
</html>
In: Computer Science
Why are FPGAs used over other programmable Devices such as the GAL chip?
In: Computer Science
Consider the given matrix (the top 250 rated movies according to IMDB). Consider a sample consist of 6 movies, after pre-processing create a data matrix for genre and movies.
Movie |
Action |
crime |
drama |
fantasy |
1 |
0 |
1 |
1 |
0 |
2 |
1 |
0 |
1 |
1 |
3 |
1 |
1 |
1 |
1 |
4 |
0 |
1 |
1 |
0 |
5 |
0 |
1 |
1 |
0 |
6 |
0 |
0 |
1 |
0 |
In: Computer Science
Pick a Distributive System of any kind and ask yourself what is
(are) being distributed? Write a Prose in one or two paragraphs of
your thoughts.
Some examples such as Processor, Memories, Networks (Transport
Mechanism) are distributed; but that are just the tips of an
iceberg. Services, Capabilities, Reliability,
just to name a few for your information.
In: Computer Science
Will the Internet and related communication technologies be tools for increasing political freedom, or will they give more power to governments to spy on, control, and restrict their people?
In: Computer Science
Using the Stack class (it's on the class web page) construct a program that will evaluate postfix (reverse Polish, more properly reverse Lukasiewicz`notation). First, create a class called Postfix. It should have one static function public static double postfix(String s) { This should take a string of tokens consisting of either double constants or the operators + - / *. It should return the value of the postfix expression as a double. The algorithm is 1) Get the next token 2) if it is an operand (double), push it onto a stack. 3) if it is an operator, pop the top two elements, combine them using the operator, and push the result. For - and /, it matters which popped operand should be used first. Entering 2 5 - should give -3. Entering 5 2 - should give 3. Similarly 4 2 / should give 2 while 2 4 / gives 0.5 When the last token is processed, the stack should contain 1 element, the anwer. You need to be prepared to detect and deal with badly formed expressions. Things to look for are an operator appearing when the stack has 0 or 1 entry and a situation where there is more than 1 item on the stack after processing the last token. Be aware of these, and any other problems that may arise, and shut the program down gracefully with a meaningful error message. In order to get the tokens 1 by 1 from the input String, you can use an instance of the StringTokenizer class. You should read about this class. The following code should do the job for you: import java.util.StringTokenizer; public class Postfix { public static double postfix(String s) { StringTokenizer st = new StringTokenizer(s, " +-/*", true); //delimiters are space, +, -, /, *. The "true" says return the //delimiter itself as a token. while (st.hasMoreTokens()) { String tok = st.nextToken(); // at this point, tok contains " ", "+", "-", "/", "*", or a String // representing a double constant. Anything else is an error. // If is a double constant, you can get the double value using // Double.parseInt(tok); If this is NOT a double constant, it will // throw an exception. The rest is up to you.
Here is the stack class
public class Stack<T> { LL<T> theStack; public Stack() { theStack = new LL<T>(); } public boolean isEmpty() { return this.theStack.isEmpty(); } public boolean isFull() { return false; } public void push(T value) { this.theStack.insertAtHead(value); } public T pop() { { return this.theStack.removeFromHead(); } } public T peek() { T retval = this.pop(); this.push(retval); return retval; } public String toString() { return this.theStack.toString(); } public static void main(String args[]) { Stack<Double> myStack = new Stack<Double>(); for (int i = 0; i < 10; i++) { myStack.push((double)i); } while (!myStack.isEmpty()) { System.out.println(myStack.pop()); } } }
In: Computer Science
Please code in C# - (C - Sharp)
Assignment Description
Write out a program that will ask the user for their name; the length and width of a rectangle; and the length of a square. The program will then output the input name; the area and perimeter of a rectangle with the dimensions they input; and the area and perimeter of a square with the length they input.
Tasks
In: Computer Science
Employees present a serious threat to the security of an organization.
Give four reasons why employees are especially dangerous to the security of an organization.
What type of employee do you think is the most dangerous? Why?
Share any experiences that you have had with insider security threats.
In: Computer Science
(10 pts) Explain why modern computers consist of multiple abstract levels and describe the main functions of each level.
In: Computer Science
BUOYANCY
Buoyancy is the ability of an object to float. Archimede's Principle states that the buoyant force is equal to the weight of the fluid that is displaced by the submerged object. The buoyant force can be computed by:
buoyant force = (object volume) times (specific gravity of the fluid)
If the buoyant force is greater than or equal to the weight of the object then it will float, otherwise it will sink.
Write a program that inputs the weight (in pounds) and radius (in feet) of a sphere and outputs whether the sphere will sink or float in water. Use 62.4 lb/cubic foot as the specific weight of water. The volume of a sphere is computed by (4/3)π times the radius cubed.
INPUT and PROMPTS. The program uses this prompt ""Input weight of the sphere in pounds." for the first number it reads in, the weight of the sphere. The program uses this prompt "Input radius of the sphere in feet." for the second number it reads in, the radius of the sphere. Do not print out these numbers as they are read in
OUTPUT. The program either prints out "The sphere will float in water." or "The sphere will sink in water.".
In: Computer Science
Write a function log2(x), which gives an integer approximation of the log base 2 of a positive number x, but it does so using recursion. Use a base case where you return 0 if x is 1 or less. In the general case, add 1 to the answer and divide x by 2. (python 3)
In: Computer Science
Describe the history of SNMP from its beginning and compare/contrast the features of the different versions. Support your rationale.
In: Computer Science
I need to find the kth smallest element in the union of 2 sorted arrays in O(log |A| + log |B|) time. I understand this is similar to binary search, but I don't understand which parts of the arrays I can throw out at each level of recursion, and why. In the pseudocode below, what should go into $1 through $16 and why?
// A and B are each sorted into ascending order, and 0 <= k
< |A|+|B|
// Returns the element that would be stored at index k if A and B
were
// combined into a single array that was sorted into ascending
order.
select (A, B, k)
return select(A, 0, |A|-1, B, 0, |B|-1, k)
select(A, loA, hiA, B, loB, hiB, k)
// A[loA..hiA] is empty
if (hiA < loA)
return B[k-loA]
// B[loB..hiB] is empty
if (hiB < loB)
return A[k-loB]
// Get the midpoints of A[loA..hiA] and
B[loB..hiB]
i = (loA+hiA)/2
j = (loB+hiB)/2
// Figure out which one of four cases
apply
if (A[i] > B[j])
if (k <= i+j)
return select(A, $1, $2, B, $3, $4, k);
else
return select(A, $5, $6, B, $7, $8,
k);
else
if (k <= i+j)
return select(A, $9, $10, B, $11, $12, k);
else
return select(A, $13, $14, B, $15, $16, k);
In: Computer Science
Write a new program named Bar that prompts the user to enter a positive integer. The program should then display a line consisting of the entered number of asterisks using a while loop. If the user enters a number that is not positive, the program should display an error message (see example below).
Example 1: Enter a positive number: 6 ******
Example 2: Enter a positive number: 11 ***********
Example 3: Enter a positive number: -4 -4 is not a positive number
In: Computer Science
A student is ready to graduate if his GPA is at least 2.0 and he is in his fourth year. Write a C++ program that will ask the student about his GPA and what year he is currently in. The program should display a message saying either the student is ready to graduate or he still needs more schooling. This program must be in C++ and must be able to run.
Thank you and I hope you have a great day!
In: Computer Science