首页 > 其他 > 详细

Bookstore project using XAMPP 详细配置 Part 3

时间:2016-03-09 12:27:15      阅读:325      评论:0      收藏:0      [点我收藏+]

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://stackoverflow.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

技术分享

 

Bookstore project using XAMPP 详细配置 Part 3

原文:http://www.cnblogs.com/wenchan/p/5257359.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!