Jump to content
Larry Ullman's Book Forums

Recommended Posts

Hello again. 
 
When I tried out the scripts demonstrating transforming strings and arrays, this is what I got:

 

 

Object not found!

The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

If you think this is a server error, please contact the webmaster.

Error 404 localhost
Apache/2.4.26 (Win32) OpenSSL/1.0.2l PHP/7.1.7

 

Here's my code for list.html:

 

<!doctype html>

<html lang="en">
<head>
   <meta charset="utf-8">
   <title>I Must Sort This Out!</title>
</head>
<body>
<!-- Script 7.6 - list.html -->
<div><p>Enter the words you want alphebetized with each individual word separated by a space:</p>
 
<form action="list/php" method="post">
 
   <input type="text" name="words" size="60">
   <input type="submit" name="submit" value="Alphabetize!">
 
</form>
</div>
</body>
</html>

 

and for list.php:

 

<!doctype html>

<html lang="en">
<head>
   <meta charset="utf-8">
   <title>I Have This Sorted Out</title>
</head>
<body>
<?php // Script 7.7 - list.php
/* This script recieves a string in $_POST['words']. It then turns it into an array, sorts the array alphabetically, and reprints it. */
 
// Address error management, if you want.
 
// Turn the incoming string into an array:
$words_array = explode(' ' , $_POST['words']);
 
// Sort the array:
sort($words_array);
 
// Turn the array back into a string:
$string_words = implode('<br>', $words_array);
 
// Print the results:
print "<p>An alphabetized version of your list is: <br>$string_words</p>";
 
?>
</body>
</html>

 

What am I doing wrong?

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...