3. Create PHP
1) “Sublime Text” is used as text editor.
2) HTML part of “hello.php” was created as shown. This file is under the directory of “\xampp\htdocs”
3) After being deployed on “localhost:85”, it shows the search boxes as below. Now it’s just the scaffold. We need to add PHP code to realize it.
4) Here comes the tricky part: PHP section. The PHP code should be used to connect to phpMyAdmin database. Also, the PHP code should achieve the search functionality.
I followed the tutorial steps but found it was not working. I got the error message of “Fatal error: Call to undefined function mysql_connect()”. So I did some research and found that all of database command starting with “mysql” such as “mysql_connect”, “mysql_select_db”, “mysql_error” etc were not working in my case. I need to change all of the commands to be started with “mysqli”.
Here, it actually corresponds to the extension setting in “config.inc.php” file in “\xampp\phpMyAdmin” directory, as I mentioned earlier in this report (please see part 1).
I also need to change the “php.ini” file under “\xampp\php” directory. I un-commented “extension_dir=”C:\xampp\php\ext”” (red box in Figure 17). Also I un-commented “extension=php_mysql.dll” and “extension=php_mysqli.dll”
5) After I made all of the changes, the PHP code looks like in the figure below. All of the places of “mysql_” commands were replaced with “mysqli_” shown in line 36, 42, 50, 53, 62, 64.
Also, since “mysqli_” is improved version of “mysql_”, some of the functions will take more parameters than before. I have read the PHP official documentation and made the corresponding changes, e.g., “mysqli_query” will need two parameters instead of 1.
Here are some references related to solving all of the problems I encountered.
a) https://www.youtube.com/watch?v=e3y57I63gCw (the comments are helpful)
b) http://*.com/questions/548986/mysql-vs-mysqli-when-using-php
c) http://php.net/manual/en/mysqli.query.php
d) http://php.net/manual/en/mysqli-result.fetch-array.php
e) http://php.net/manual/en/mysqli.error.php
f) http://www.w3schools.com/php/func_mysqli_select_db.asp
6) Finally the interface and search implementation