1 / 90

CS 360 Information on EasyPHP

CS 360 Information on EasyPHP. Based on Information in PHP, MySQL , and JavaScript, by Robin Nixon Prepared by Kirk Scott. Introduction to EasyPHP and MySQL. This version of the document contains a summary of the instructions given in the book, as well as solutions to roadblocks.

oliver
Télécharger la présentation

CS 360 Information on EasyPHP

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 360Information on EasyPHP Based on Information in PHP, MySQL, and JavaScript, by Robin Nixon Prepared by Kirk Scott

  2. Introduction to EasyPHP and MySQL • This version of the document contains a summary of the instructions given in the book, as well as solutions to roadblocks. • This document is a simplified replacement for the content in the Nixon book. • Assuming that you have a question or a problem, before concluding that there is no answer or solution to it, do a quick scan of all of the points covered in this document.

  3. The most important thing to keep in mind is this: • This document is provided as a survey of where the things came from that became part of the project • It is not intended to be a complete replacement for a resource on Web development of a MySQL database

  4. The Web is the most up to date resource on how to accomplish the kinds of things required • Check out this Web site: • http://www.w3schools.com/ • The existence of sites like these have rendered lots of textbooks more or less obsolete

  5. Part I. Downloading and Installing EasyPHP with MySQL, etc. Topics in Chapter 2 of the Book.

  6. A. Installing EasyPHP as a local Windows, Apache, MySQL, and PHP development server. • 1. Go to this address: • www.easyphp.org • A screenshot is given on the next overhead

  7. 2. Click the download button near the upper right hand corner of the screen. • 3. Follow the instructions for downloading; then follow the instructions for installing.

  8. B. Running and Using EasyPHP. • 1. At the end of a successful installation you will automatically be taken to the EasyPHP Help page. • As usual, the installation may be fraught with little difficulties. • It’s possible to actually install successfully, but have it not go to the help page.

  9. If that happens, just type in the URL yourself. • http://127.0.0.1/home/en/index.html • Different versions may have slightly different addresses • This matter of different addresses will recur in these overheads • A screenshot of what you might see is given on the next overhead.

  10. 2. The help page provides this initial information: • 3. A successful installation should put an EasyPHP icon in the system tray at the bottom of the screen. • 4. Double clicking on the icon allows you to check whether Apache and MySQL are running, and restart them if they're not.

  11. 5. Right clicking on the icon gives a menu including these options: Administration, Local Web, Restart, and Stop. • 6. Administration allows you to display your database, once it's created. • 7. Local Web allows you to display your files, once you have files to display.

  12. 8. Restart and Stop allow you to start and stop EasyPHP in its entirety, rather than dealing with Apache and MySQL individually. • 9. Over time, you may discover that EasyPHP stops on its own for unknown reasons. • This is the way to start the whole thing running again.

  13. C. Testing EasyPHP. • 1. Right click on the EasyPHP icon in the system tray and take the Local Web option in the menu. • A screenshot is shown on the next overhead

  14. 2. The Web browser will open to a URL of this form: http://127.0.0.1:8888/. • 3. This is the address for the local host with port 8888 instead of port 80, the usual default for a Web host. • Depending on the version you have installed, the address may have 8887 or some other value. • EasyPHP does this in order to avoid conflicts with other programs that use the network.

  15. 4. What you are seeing on this page is a directory listing for the home directory for the server, which should initially be empty. • 5. Now right click on the EasyPHP icon in the system tray and take the Administration option in the menu. • A screenshot is shown on the following overhead

  16. 6. A Local Web will be listed, showing a path name on the computer. • 7. If you click on the Root option, this will take you to the directory you just accessed through the previous steps. • 8. If you want to, you can take the Alias option and set up a directory different from the default directory to work in.

  17. D. Possible Problems. • 1. Attempting to run EasyPHP may generate Apache or MySQL errors. • 2. These errors may indicate that an attempt has been made to access a blocked port. • 3. Firewalls, antivirus and other security programs, Skype, etc. may block ports.

  18. 4. In general, port 80 (or its equivalent) has to be available for Apache and port 3306 (or its equivalent) has to be available for MySQL. • EasyPHP defaults to port 8888 or 8887 or some other port, but conflicts with this port would still be possible. • 5. No attempt will be made here to summarize how to debug and fix problems with port access.

  19. 6. I looked into it a little and discovered that a Web search on the topic brought up useful information at the Web site superuser.com, for example. • 7. Needless to say, if you have problems like these, trying to fix them could take you down a long and winding path.

  20. 8. Another possible source of problems is that depending on the version of Windows you're using, the installation directory of EasyPHP might not end up with the right default security permissions. • 9. The directory where EasyPHP is installed, and its subdirectories, should have write access for all users. • 10. Go to the EasyPHP directory in the Program Files directory, right click on it, take the Properties option in the menu, and click on the Security tab to check on this.

  21. Part II. Working with MySQL. Topics in Chapter 8 in the Book.

  22. A. There is a graphical user interface for MySQL on EasyPHP. • 1. The GUI is accessed through the phpMyAdmin page, which can be found at this address: http://127.0.0.1:8888/home/mysql/. • 2. You can certainly use the GUI if you want to • If you do, you can figure it out yourself. • 3. Everything that you need to do can be accomplished through the command line interface, and it will be covered below.

  23. B. Accessing the MySQL Command Line Interface. • 1. You can get to a command prompt in Windows by clicking the Start button and either entering cmd into the text field at the bottom or going to the list of all programs and looking in the Accessories folder. • 2. At the command prompt, using cd and dir, you want to navigate to this folder, where x.x.x.x stands for whatever version of EasyPHP you installed: • C:\Program Files\EasyPHP-x.x.x.x\mysql\bin.

  24. 3. Enter this command at the prompt in order to log in as the root: mysql –u root –p. • 4. If successful, the command will prompt you for a password. • 5. As the root, you don't need a password, so you complete the login by hitting the enter key.

  25. 6. You will be greeted by some jargon about the program, followed by this statement: • Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. • 7. This will be followed by the mysql command prompt: mysql>

  26. C. Using the MySQL Command Prompt. • 1. MySQL contains database management commands in addition to vanilla SQL DDL and DML commands. • 2. Suppose you enter this command: • SHOW databases • You should be shown a list of all databases currently in existence and being managed by the installation of MySQL you're working with.

  27. 3. If everything has gone OK with the installation so far this is what you should see as a result: • +--------------------+ • | Database | • +--------------------+ • | information_schema | • | mysql | • | phpmyadmin | • +--------------------+

  28. 4. If you type in a complete SQL command, with a semicolon at the end, and it's in error, you will get an audible warning that something is amiss. • 5. You will quickly discover that MySQL commands have to be followed by a semicolon.

  29. Typing in anything that doesn't end with a semicolon, whether a partial or complete command, will take you to a sub-prompt of this form: . • This tells you that MySQL is waiting for the rest of a command or the completion of a command. • If you already typed it all in except for the semicolon, you can just enter the semicolon at this prompt, followed by the enter key, and the command will be executed.

  30. D. Creating a New Database. • 1. It is simple to create a new database. Enter a command of this form: • CREATE DATABASE DatabaseName; • 2. You can verify that it has been created by repeating this command: • SHOW databases;

  31. E. Creating Users and Granting Access. • 1. In the long run you would probably want to have a regular login rather than using the Root login. • 2. The Root has the ability to create other users. The command is: • CREATE user Userid;

  32. 3. It is possible to set a password for the user, but for the time being doing that isn't critical. • 4. Once a database has been created and a user has been created, the user can be granted access to the database with this command: • GRANT ALL ON DatabaseName.* TO 'Userid';

  33. F. Using Databases and Exiting MySQL. • 1. If you enter the 'help' command, you will be shown a list of all MySQL (system) commands. • The commands in this list that you can't live without are: • USE, EXIT, QUIT.

  34. 2. If a user has been granted access to a database and wants to use the database, it is necessary to enter this command: • USE DatabaseName; • 3. When a user is finished and wants to leave the MySQL command prompt, it's necessary to enter either of these two commands: • EXIT; QUIT;

  35. G. Creating Tables and inserting Data in MySQL. • 1. At this point you can apply your knowledge of SQL to create tables with CREATE TABLE commands. • 2. Since table creation was illustrated with Microsoft Access, it's worthwhile to note a few of the difference between the implementation of SQL in that product and SQL in MySQL.

  36. 3. The TEXT type exists in MySQL, but it is not the preferred type. CHAR or VARCHAR are preferred. • There are subtle differences between VARCHAR and TEXT, the most important being that if you choose to index on a TEXT field, you have to specify how many characters to index on.

  37. 4. The CURRENCY data type doesn't exist in MySQL. • The preferred type for declaring monetary fields is DECIMAL. • A declaration of a DECIMAL field takes this form: • DECIMAL(m, n). • m tells the total number of digits the number can contain. • n tells how many of those digits follow the decimal point.

  38. 5. MySQL supports an AUTO_INCREMENT type, which may be useful for primary key fields. • 6. There is another useful command in MySQL: • DESCRIBE TableName. • This gives you a summary of the design of the table, separate from the SQL table creation statement.

  39. 7. Keep in mind that part of the requirements for the project is documenting table designs. • Some combination of SQL CREATE TABLE commands and output from the DESCRIBE command should provide this information.

  40. 8. If you're working at the command prompt, it will probably be convenient to create longer statements in an editor and then paste them into the command prompt. • If you're working with the GUI, you will have to explore to find out how you might generate the information you'll need for documentation.

  41. 9. After table creation is complete, initial data insertion is the next task. • If you're working at the command prompt, SQL INSERT statements can be used. • Although this may seem inconvenient, it isn't really.

  42. You can easily prepare long sequences of similar insertion statements in an editor and then paste them into the command prompt. • This has the advantage that if something goes wrong, you can always repopulate the tables with the saved files containing the insertion statements. • If you're working with the GUI, you'll have to explore to find out the most effective way to insert data.

  43. 10. When writing insertion statements (and later on, when writing queries) keep in mind that MySQL doesn't recognize # signs for enclosing date values. • Date field values should be enclosed in single quotes, just like CHAR or VARCHAR values.

  44. H. Indexing in MySQL. • 1. In the presentation of indexing earlier in the semester, creating an index was handled separately from creating the table which had the index. • This can be done with MySQL. • 2. It was also pointed out that under the covers, primary key field characteristics are typically enforced by default indexes on those fields. • This also holds true in MySQL.

  45. 3. MySQL also supports syntax for specifying an index as part of the table definition. • 4. Indexing in MySQL involves certain complexities. • For example, it supports different kinds of indexes. • One is specified by including this keyword phrase after the declaration of the index: • ENGINE MyISAM.

  46. 5. The details of these complexities are of no consequence. • After unit 19 you will be in a position to appreciate at least in part what's going on. • ISAM stands for indexed sequential access method. • What you can infer is that supporting an index may involve the organization and storage of the file itself.

More Related