![]() ![]() Then I run my query and display the result as an HTML table. Here, I call mysqli_init(), set the credentials and call mysqli_real_connect() to get the connection handle. Query("select iata,name from airports where country='Greenland' order by 2") Įcho "". So, for my first lines of PHP I’ve added the following to C:\MAMP\htdocs\index.php: Records: 12 Deleted: 0 Skipped: 0 Warnings: 0 Records: 260 Deleted: 0 Skipped: 0 Warnings: 0 Records: 67663 Deleted: 0 Skipped: 0 Warnings: 0 Records: 7184 Deleted: 0 Skipped: 0 Warnings: 7184 Query OK, 7184 rows affected, 7184 warnings (0.12 sec) Records: 6162 Deleted: 0 Skipped: 0 Warnings: 4 Query OK, 6162 rows affected, 4 warnings (0.04 sec) Now, if you are still in the unzipped directory, you can load data with the source sql\load-data.sql script which loads from the data\*.dat files This has created the flightdb2 database, with openflights user, and 15 tables. The MySQL connection parameters are displayed on including the password (root) I’m used to Oracle where I can port my code and scripts from one platform to the other, and was a but surprised by this.Ĭ:\MAMP\bin\mysql\bin\mysql test -port=3306 -host=localhost -user root -password We have to remove them before running the SQL scripts. I go to the unzipped directory and run MySQL:Īnother little thing to fix here: the sql\create.sql and sql\load-data.sql files contain some lines starting with “\! echo” but this \! command (to run a system command) exists on Linux but not on the Windows port of MySQL. I want to initialize the database with some data and I’ll use the OpenFlights database. Well, I’ve never written one line of PHP and I already hate it for its error handling weakness. I’ve changed it to (count($analyzed_sql_results) = 1 ) as I suppose they want to count and compare to one. The line 615 shows count($analyzed_sql_results = 1 ) which is probably not correct because it counts a boolean expression. The message is about count() not having the correct parameter. Fortunately, the message is clear: line 615 of C:\MAMP\bin\phpMyAdmin\libraries\ My common sense tells me that we should set display_errors=on and test a few screens before releasing a software. You will see that parentheses are missing, this is a syntax error and raising only a warning for that is quite bad. So this product, which is free but has also a ‘PRO’ version, probably running the same code, is delivered with bad code, raising errors that were ignored. MAMP "count(): Parameter must be an array or an object that implements Countable" Warning: mysqli_real_connect(): (28000/1045): Access denied for user (using password: YES) in C:\MAMP\htdocs\index.php on line 123īut now that I display the errors, I get this annoying message each time I try to do something in phpMyAdmin (which runs as PHP in the same Apache server): The current setting is displayed in and I can change it in C:\MAMP\conf\php7.2.1\php.ini and after a restart of the Apache server I can see full error messages: ![]() I have to set display_errors=on for that. But I’m there to play and I want to see the error messages and line numbers. This configuration is ok for production because displaying errors may give clues to hackers. With the default configuration, Apache just raises and Error 500 which does not help me a lot for debugging. I’ll write some PHP and because it’s the first time in my life, I will have some errors. With all defaults (Apache on port 80) my web server pages are on (serving the files in C:\MAMP\htdocs) and administration page is at The MySQL administration page (phpMyAdmin) is at It seems that, at least by default, I don’t need a password to go to the admin pages. The first time you start the servers, the Windows Firewall configuration is raised and you have to accept it: All that is installed under C:\MAMP (you can change it, I just kept the default settings). A setup menu to configure them, but I keep the default. This bundle is very easy to use: a simple window to start and stop the servers (Apache and MySQL). ![]() What? Reboot? Seriously, we are in 2018, that’s Windows 10, I refuse to reboot to install a simple Apache server! exe, all is straightforward and the installer notifies me that the installation will be completed after a reboot. So MAMP is like LAMP (Linux Apache PHP MySQL) but with a M for MacOS, but also Windows (W being an upside-down M after all). Thus, I’ve to look at MAMP, PHP and MySQL for the first time… And I decided to load the OpenFlights open data to play with. They install MAMP (My Apache – MySQL – PHP) during their curriculum for website development, and then I’ll use this environment to teach data modeling and SQL basics. I’ll detail in a future blog post but the idea is giving a short introduction to databases to students at, a coding academy for refugees in Switzerland. You may wonder what I’m doing with those technologies that are completely different from what I usually do.
0 Comments
Leave a Reply. |