Walking Trip …

Walking Trip

Walking Trip

Offenbach's Suite ... Warts 'n All

Offenbach's Suite ... Warts 'n All

If this was interesting you may be interested in this too.

Posted in Photography, Trips | Tagged , , , , , , , , , | 336 Comments

HTML/Javascript Visual Change Drop Punt Game Tutorial

HTML/Javascript Visual Change Drop Punt Game Tutorial

HTML/Javascript Visual Change Drop Punt Game Tutorial

Do you love the game of Australian Rules? Even if you don’t, are you interested in the art of kicking the Australian Rules football (most famously, the “Sherrin“)? Haven’t heard of any great players that do not agree on the drop punt being the most effective kick to use these days, but even though it might be more reliable than any drop kick or other kicking idea, it can still be hard to get right, and today’s tutorial is not pretending it is at all easy, but plays the “behind the scenes” idealized physics behind kicking the ball. The game pares it all down to an elevation angle of your initial contact with the football and a metres/second velocity that you kick the ball. All that being the way it is, and the world has no drag, nor friction, and is straight (no fights in Kings Cross, methinks?), how far will the football go, and how high will it go? You’ll be pleased to hear that we have no bias here at RJM Programming, and there is no Collingwood positive bias applied to users who are of that persuasion.

Hope you get some interest out of today’s drop punt kicking game building on previous HTML/Javascript Visual Drop Punt Game Tutorial as shown below, by agreeing with that adage that every three pictures is worth three thousand words, by adding a Google Scatter Chart and (if on two or more passes within a session), adding a Google Scatter Difference Chart, to show the “fantasy” drop punt kick trajectory comparisons (height scales are exaggerated) in visual form, with the idea that comparing Scatter Charts can help the kicker get a feel for how to tweak their kick to get a better result (for the scientifically minded players … whyyyyyyyyyyyyy iz it sssoooooooooo?)

Three links, in particular, helped, so, thanks:

Very close to finally, will leave you with some downloadable HTML programming source code you could call dropvisualchangepunt.html for your perusal.

Very very nearly finally, have a look at the differences in code that arrived at all the extra visual Google Scatter Chart “visual trajectory” functionality by examining All Changes regarding Scatter Chart Visuals link.

Finally, have a look at the differences in code that arrived at the comparison part of the extra visual Google Scatter Chart “visual trajectory” functionality by examining Changes just for Scatter Chart Visual Comparisons link.


Previous HTML/Javascript Visual Drop Punt Game Tutorial is shown below.

HTML/Javascript Visual Drop Punt Game Tutorial

HTML/Javascript Visual Drop Punt Game Tutorial

Do you love the game of Australian Rules? Even if you don’t, are you interested in the art of kicking the Australian Rules football (most famously, the “Sherrin“)? Haven’t heard of any great players that do not agree on the drop punt being the most effective kick to use these days, but even though it might be more reliable than any drop kick or other kicking idea, it can still be hard to get right, and today’s tutorial is not pretending it is at all easy, but plays the “behind the scenes” idealized physics behind kicking the ball. The game pares it all down to an elevation angle of your initial contact with the football and a metres/second velocity that you kick the ball. All that being the way it is, and the world has no drag, nor friction, and is straight (no fights in Kings Cross, methinks?), how far will the football go, and how high will it go? You’ll be pleased to hear that we have no bias here at RJM Programming, and there is no Collingwood positive bias applied to users who are of that persuasion.

Hope you get some interest out of today’s drop punt kicking game building on previous HTML/Javascript Drop Punt Game Tutorial as shown below, by agreeing with that adage that every picture is worth a thousand words, by adding a Google Scatter Chart to show the “fantasy” drop punt kick trajectory (height scale is exaggerated) in visual form.

Three links, in particular, helped, so, thanks:

Almost finally, will leave you with some downloadable HTML programming source code you could call dropvisualpunt.html for your perusal.

Very nearly finally, have a look at the differences in code that arrived at this extra visual Google Scatter Chart “visual trajectory” functionality by examining dropvisualpunt.html link.

Finally, we will take this a step (or a kick … chortle, chortle) further, tomorrow.


Previous HTML/Javascript Drop Punt Game Tutorial is shown below.

HTML/Javascript Drop Punt Game Tutorial

HTML/Javascript Drop Punt Game Tutorial

Do you love the game of Australian Rules? Even if you don’t, are you interested in the art of kicking the Australian Rules football (most famously, the “Sherrin“)? Haven’t heard of any great players that do not agree on the drop punt being the most effective kick to use these days, but even though it might be more reliable than any drop kick or other kicking idea, it can still be hard to get right, and today’s tutorial is not pretending it is at all easy, but plays the “behind the scenes” idealized physics behind kicking the ball. The game pares it all down to an elevation angle of your initial contact with the football and a metres/second velocity that you kick the ball. All that being the way it is, and the world has no drag, nor friction, and is straight (no fights in Kings Cross, methinks?), how far will the football go, and how high will it go? You’ll be pleased to hear that we have no bias here at RJM Programming, and there is no Collingwood positive bias applied to users who are of that persuasion.

Hope you get some interest out of today’s drop punt kicking game.

Three links, in particular, helped, so, thanks:

Finally, will leave you with some downloadable HTML programming source code you could call droppunt.html for your perusal. We extend the visual aspects to the functionality when we revisit this posting on 09/05/2014.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in Data Integration, Games, Software, Tutorials, eLearning | Tagged , , , , , , , , , , | 12 Comments

Image Gallery Figcaption Primer Tutorial

Image Gallery Figcaption Primer Tutorial

Image Gallery Figcaption Primer Tutorial

We have a new slideshow presentation, or image gallery web application idea, today. It uses in its methodologies the HTML figcaption tag, new to HTML5, and useful, in that it associates images with explanatory words, though you don’t have to follow the “every picture tells a thousand words” adage here, as you add your optional caption data.

Think, though, if you do caption when trying out today’s proof of concept PHP gallery_via_figcaption.php‘s live run link, that captions make your image galleries that much better.

We’re pretty sure we’ll be improving this web application’s functionality over time, but in the meantime, we hope it helps you out with some image presentation ideas, and we’ll add the idea onto our list of presentation ideas at PDF on Mac OS X via Images and Finder and Preview Tutorial.

You can also see this play out at WordPress 4.1.1′s Image Gallery Figcaption Primer Tutorial.

If this was interesting you may be interested in this too.

Posted in Tutorials, eLearning | Tagged , , , , , , , , , , , , | Leave a comment

HTML Datalist Tag Country Flag Quiz Tutorial

HTML Datalist Tag Country Flag Quiz Tutorial

HTML Datalist Tag Country Flag Quiz Tutorial

Sometimes there’s quite a big difference between the optimism a proof of concept project can engender, and the application of that to a real world application. The use of HTML Datalist Tag Primer Tutorial‘s road testing of the datalist tag, new to HTML5, is a case in point today, as we set about thinking how to best apply this new (we still think) useful functionality to another application.

For this first datalist application of functionality we thought of the Country list dropdowns featured in our Country via Capital Placeholder Quiz Game Tutorial series of blog postings. Along the way we “lost” all but Firefox “Country Flag Quiz” (and not sure about Internet Explorer and Microsoft Edge) via …

  • Safari 12 and under and Internet Explorer 9 and under do not recognize the datalist tag (at time of writing)
  • Google Chrome lacks overflow-y:scroll capability when there are a lot of options
  • Opera behaves like Chrome
  • Usage did not suit “Country Currency Quiz” nor “Country Capital Quiz”

The changed country_flag_quiz.php‘s live run is your opportunity to (at least with Firefox) see how this (ComboBox like) HTML(5) datalist tag can be incorporated into your web applications.

After all that, how does the “(we still think) useful functionality” stack up? Well, the online world changes fast, and am sure the web browser brands, other than our virtuous Firefox one (today), will get onto better support regarding this known problem.

You can also see this play out at WordPress 4.1.1′s HTML Datalist Tag Country Flag Quiz Tutorial.


Previous relevant HTML Datalist Tag Primer Tutorial is shown below.

HTML Datalist Tag Primer Tutorial

HTML Datalist Tag Primer Tutorial

The release of HTML5 brought with it a smorgasbord of improvements, not all of them supported on all the platforms and web browsers … hopefully, this does not make you cross?!

Am really happy, today, to remind you of an HTML5 newly released HTML tag, the datalist tag. To me, this one goes into the “old chestnut” categorization, because this datalist tag completes for me (and improves on) a wish I’ve had forevvvveer with HTML(5) … give me a tag like the totally brilliant (GUI feature called) ComboBox Class (System.Windows.Forms) | Microsoft Docs. The ComboBox of the Windows Forms (desktop application) days (which still exist of course) combined …

  • need to be prompted for ideas regarding a data item … the “dropdown” bit of a ComboBox … while also attending to the …
  • need to allow users knowing “exactly” what they want, having the flexibility to type in “exactly” what they want (with the keyboard)

… cute, huh?! And then to my mind, not sure whether the Windows Forms ComboBox has come along too over time, but noticed writing today’s datalist_poc.html “proof of concept” live run that the joy you get from a (HTML input) textbox remembering a past entry is reflected in an updated (even with an HR element separating) “dropdown” list member to the datalist tag … cuter still, huh?!

“But there’s more”. The datalist tag performs autocompletion functionality via the words of its dropdown list. Cuteness instilled, huh?!

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in Event-Driven Programming, Tutorials, eLearning | Tagged , , , , , , , , , , , , , , , | Leave a comment

WiFi Problems on iPad Troubleshooting Tutorial

WiFi Problems on iPad Troubleshooting Tutorial

WiFi Problems on iPad Troubleshooting Tutorial

As we mused in Google and Mac OS X Date and Time Troubleshooting Tutorial

The true art of troubleshooting, in I.T. software or hardware or networking, is to live “in the moment”, and be mindful.

… to which we’d add “try to be logical” and “try to be open to suggestion”.

Our troubleshooting scenario today revolves around an iPad and we can say about the problem …

  • the cause of the problem is very unclear
  • the problem’s symptoms are very clear … the Internet (“Safari cannot open the the page”) and email (via the Mail app) are not working, and when you bring up the iPad’s Settings -> General -> WiFi it shows a constantly spinning status, albeit to the correct Wireless Router for the house

My initial illogical phase … not following the advice above … saw me …

  • failing to fix by iPad’s Settings -> General -> WiFi … turning it Off then On (with various pauses in between)
  • failing to fix by iPad’s Settings -> General -> WiFi … click/touch “Forget Network” link … and re-entering Wireless Router password into the iPad Keychain
  • failing to fix by powering iPad Off then On

… at which point I heeded the “try to be logical” and “try to be open to suggestion” ideas above and fed into a Google search …


https://www.google.com.au/search?q=ipad+wi-fi+keeps+spinning&ie=utf-8&oe=utf-8&client=firefox-b-ab&gfe_rd=cr&dcr=0&ei=2WcvWoyiE4_p8wfn25L4DQ

… the top link of which got us to (spoiler alert … it worked) the advice of …


https://discussions.apple.com/thread/5044538

… and the first of six ideas worked (and so we figured if this happened to us, out of five other ideas, it is likely to help you too) …

Turn Off your iPad. Then turn Off (disconnect power cord for 30 seconds or longer) the wireless router & then back On. Now boot your iPad. Hopefully it will see the WiFi.

… and am figuring you networking geniuses out there could fill in some detail to answer “the cause of the problem is very unclear” from this remedy?! For ourselves, we’re just really happy to see the good old iPad working again. It is interesting to reflect though, how limited an iPad feels, functionality wise, when it loses touch with the Internet. Know there are a swathe of readers out there that find the concept of a computer device not able to reach the Internet quite amusing, am sure. Contrast this to how useful a MacBook Pro (laptop) can be doing “web application development” with (a local Apache/PHP/MySql web server like) MAMP installed, and no need for an Internet connection for testing functionality that does not involve absolute URLs.

You can also see this play out at WordPress 4.1.1′s WiFi Problems on iPad Troubleshooting Tutorial.


Previous relevant Google and Mac OS X Date and Time Troubleshooting Tutorial is shown below.

Google and Mac OS X Date and Time Troubleshooting Tutorial

Google and Mac OS X Date and Time Troubleshooting Tutorial

The true art of troubleshooting, in I.T. software or hardware or networking, is to live “in the moment”, and be mindful. All buzzwords these days, but worth noting.

But it is true, and often when you eventually do nut out a troubleshooting issue, you look back on it, and if your solution has annoyed you in taking too long to work out, it is often the fault of your lack of mindfulness, and objective logical reasoning perhaps.

Let me give you a real world example of this, that we summarize with today’s tutorial picture. Recently, my MacBook Pro lost connections to all of Google’s websites such as …

… knew this for all but the last by navigating to them from any browser’s address bar on this MacBook Pro. For the last one, knew there was an issue at RJM Programming landing page. It didn’t matter which of these web browser “brands” we picked …

  • Firefox
  • Safari
  • Google Chrome
  • Opera

… but all other websites I tried were okay, such as Yahoo search engine. Curious, huh?!

My troubleshooting involved, where I’ll give myself a “tick” for okay, and a “cross” for lack of mindfulness …

  • the different web browser test … “tick”
  • the different website test … “tick”
  • was late at night … will live without Google in my life … hope I don’t have nightmares?! So did that and said that I’d try rebooting the MacBook Pro in the morning to see what happens … “cross” … in the morning it panned out to be the same

… and here, with the benefit of hindsight, is how I could have had a solution within a few minutes of finding the problem …

  • the different web browser test … “tick”
  • the different website test … “tick”
  • the different device test … “tick” … to establish whether it relates to a particular device only … had I done this I may not have even needed to “consult” the Yahoo search engine for a solution … which is what ended up solving the problem
  • before resorting to any reboot, and the step above would have told me the problem was confined to my MacBook Pro only, mindfulness could have helped, and if I’d asked … “What’s changed recently?” … we’d have had to have answered … “We just changed the Date and Time of the MacBook Pro.” … and a recheck of that would have had us realize that we’d done that change incorrectly … as they say in Northern Ireland “Your head’s a marley.” … I’d set the month to July rather than August, but was, drowsily unaware of this because the “Thursday 11:20 pm” that was sitting up the top right of the MacBook Pro screen (at that time) would have looked okay … and a recheck of the “last thing I’d done”=”Date and Time setting” would have tweaked me to the issue … “tick”
  • but even if mindfulness like above is not available, even an analysis of the error message would have been good … on Opera, it was …

    Your connection is not private

    This server could not prove that it is www.google.com.au; its security certificate is supposedly from 20 days in the future. This may be caused by a misconfiguration or an attacker intercepting your connection.
    You cannot proceed because the website operator has requested heightened security for this domain.
    Back to safety
    Help me understand

    When you connect to a secure website, the server hosting that site presents your browser with something called a “certificate” to verify its identity. This certificate contains identity information, such as the address of the website, which is verified by a third party that your computer trusts. By checking that the address in the certificate matches the address of the website, it is possible to verify that you are securely communicating with the website you intended, and not a third party (such as an attacker on your network).

    You cannot visit www.google.com.au right now because the website uses HSTS. Network errors and attacks are usually temporary, so this page will probably work later.

    … and the feeding of the non-specific bits of some of the erroneous message bits resulted in a Yahoo search engine result set containing a useful first link website, thanks, that the reading of tweaked me into …

    1. realizing it was a Date and Time set wrongly (as might the intensive reading of the error message with the “20 days” bit suggest … “mindfulness” would point you towards “really reading” what is presented to you as evidence), on the MacBook Pro that was most likely the issue … plus the “mindfulness” jolt to remember that …
    2. that explanation “tees up” with what I was doing last on the MacBook Pro …

      maybe I did the Date and Time wrongly

    … and so it came to pass … and so the issue was fixed … “tick”

So “mindfulness” is one aspect to this. It’s also really interesting that it is Google and all its affiliated functionality, that is your “wake up caller” regarding this “once in a blue moon” … but blue moons do happen … event.

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in Uncategorized | Leave a comment

Python MySql Connector Blob Tutorial

Python MySql Connector Blob Tutorial

Python MySql Connector Blob Tutorial

No, Nala, we can’t see The Blob for the 743rd time today. But we can discuss “blob” in terms of MySql database file storage. It’s that, or a bath?! Okay, that’s settled, so make yourself comfortable with your favourite bone while we slither through our “Python MySql Connector Blob Tutorial”

In the past we’d talked about Python and MySql connections on a MacBook Pro under Mac OS X with Python MySql Connector Primer Tutorial. Today, we’re reacquainting and updating the knowledge, and here, at macOS Mojave Version 10.14, on this MacBook Pro we got a great heads up from this great link, thanks, about writing an INSERT/UPDATE/SELECT style application to download a Python command line application to store and update and retrieve binary files, such as image files, into and out of a MySql database table, in our case a MAMP local Apache/PHP/MySql web server one that uses port 8889 and a /Applications/MAMP/tmp/mysql/mysql.sock socket file (thanks for the connection advice, you guessed it, Stackoverflow) via the reinstall


sudo pip install mysql-connector

… that you need should you first get the error …


ImportError: No module named mysql.connector

… on revving the engines of macOS Mojave Terminal application command line (and we’re assuming you have Python installed here, otherwise “pip” makes no sense, unless) via …


python readblob.py

Now this code just shows the use of a MySql table already primed, rather than the Python application priming it. What steps did we take to “prime” the MAMP MySql database “testdb” that we coded for …

  1. started up MAMP
  2. clicked its “Open WebStart Page” button (to a Safari web browser webpage)
  3. clicked the link to (great, brilliant, marvellous) phpMyAdmin
  4. create “testdb” database, as required, via (click of) “SQL” button …

    create database testdb

    … Go button(click) scenario
  5. be in “testdb” database via click of its link down the left hand side
  6. create `IMAGES` table via (click of) “SQL” button …

    CREATE TABLE `IMAGES` (
    `id` int(11) NOT NULL,
    `photo` longblob NOT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

    … Go button (click) scenario

The Python code (just “def main” detail and MySql connection code tweak changed from this great link, thanks) at startup here makes a connection to a MAMP (running) MySql database via …


from mysql.connector import MySQLConnection, Error,connect

db_username='root'
db_password='root'
database_name='testdb'
db_host='127.0.0.1'

def main():
write_blob(1,"whyno.jpg")
update_blob(1, "svg_map.jpg")
read_blob(1,"02.jpg")

if __name__ == '__main__':
main()

… respectively …


def read_file(filename):
with open(filename, 'rb') as f:
photo = f.read()
return photo

def write_blob(author_id, filename):
# read file
data = read_file(filename)
# prepare update query and data
query = "INSERT INTO `images` (`id`,`photo`) VALUES (%s,%s)"
args = (author_id,data)
try:
cnx = MySQLConnection(user=db_username, password=db_password, host=db_host, port='8889', \
unix_socket='/Applications/MAMP/tmp/mysql/mysql.sock', database=database_name)
cursor = cnx.cursor()
cursor.execute(query, args)
cnx.commit()
except Exception as e:
print(e)
finally:
cursor.close()
cnx.close()

… and …


def update_blob(author_id, filename):
# read file
data = read_file(filename)
# prepare update query and data
query = "UPDATE images " \
"SET photo = %s " \
"WHERE id = %s"
args = (data, author_id)
try:
cnx = MySQLConnection(user=db_username, password=db_password, host=db_host, port='8889', \
unix_socket='/Applications/MAMP/tmp/mysql/mysql.sock', database=database_name)
cursor = cnx.cursor()
cursor.execute(query, args)
cnx.commit()
except Exception as e:
print(e)
finally:
cursor.close()
cnx.close()

… and …


def write_file(data, filename):
with open(filename, 'wb') as f:
f.write(data)

def read_blob(author_id, filename):
# select photo column of a specific author
query = "SELECT photo FROM images WHERE id = %s"
try:
cnx = MySQLConnection(user=db_username, password=db_password, host=db_host, port='8889', \
unix_socket='/Applications/MAMP/tmp/mysql/mysql.sock', database=database_name)
cursor = cnx.cursor()
cursor.execute(query, (author_id,))
photo=cursor.fetchone()[0]
# write blob data into a file
write_file(photo, filename)
except Exception as e:
print(e)
finally:
cursor.close()
cnx.close()

… for an initial phpMyAdmin database: testdb `images` link click Browse link that showed …

id photo

… for us, where the folder of readblob.py had existant whyno.jpg and svg_map.jpg but no 02.jpg until …


$ ls -l whyno.jpg svg_map.jpg 02.jpg
ls: 02.jpg: No such file or directory
-rw-r--r--@ 1 user admin 570207 7 Feb 21:18 svg_map.jpg
-rw-r--r--@ 1 user admin 423196 19 Mar 19:39 whyno.jpg
$ python readblob.py
$ ls -l whyno.jpg svg_map.jpg 02.jpg
-rw-r--r-- 1 user admin 570207 22 Apr 13:36 02.jpg
-rw-r--r--@ 1 user admin 570207 7 Feb 21:18 svg_map.jpg
-rw-r--r--@ 1 user admin 423196 19 Mar 19:39 whyno.jpg
$

… whereby phpMyAdmin database: testdb `images` link click Browse link then showed …

id photo
1 [BLOB - 556.8 KiB]

… giving you (in addition to a glint in the eye of a Steve McQueen up there somewhere) a blueprint for a slytherin good time hangin’ out with MAMP … chortle, chortle … not forgetting good ol’ 02.jpggood times.

You can also see this play out at WordPress 4.1.1′s Python MySql Connector Blob Tutorial.


Previous relevant Python MySql Connector Primer Tutorial is shown below.

Python MySql Connector Primer Tutorial

Python MySql Connector Primer Tutorial

In the past we’ve teamed Python (server side language) up with the MySql (database) via a python module called MySQLdb when we presented Python MySql Circle and Point DataTable Primer Tutorial below. Then, we shared the Mac OS X MAMP local web server’s MySql instance (teamed with Apache and PHP (server side language)) to perform some SQL (of the MySql ilk) regarding the storage of some Circle and Point database tables and data.

Moving on today, we are acting as though MAMP was never installed … what blasphemy! … because, in all likelihood, that is likely to be the case if Python has been chosen as your primary serverside language, rather than PHP … what gall?! …

So what’s the go with MySql these days? For us, here at Mac OS X macOS 10.12.3 (on a MacBook Pro) …


mysql Ver 8.0.11 for macos10.13 on x86_64 (MySQL Community Server - GPL)

What port is listening for a non-MAMP MySql installation?


3306 is default

What is the latest Python version as of today?


Python 3.6.5

… accessed via “python3″ concurrent with an older 2.7.10 version accessed via “python”, on Mac OS X (Terminal bash) command line.

What links MySql to Python3?


mysql-connector-python-8.0.11-macos10.13.dmg installs module mysql.connector (or called "Connector/Python" at MySql webpages) via ...
pip 10.0.1 from /Library/Python/2.7/site-packages/pip (python 2.7) via ...
pip install mysql-connector-python-rf

Any symlinks needed to make “command line” life easier? Yes …


sudo ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
sudo ln -s /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip /usr/local/bin/pip

… so that …


mysql -uUserName -pPassWord

… starts a MySql (port 3306 listener) session ready for SQL DDL and DML commands.

In summary, for a MacBook Pro initially just having the MAMP MySql (that listens on port 8889) and Python 2.7.10, we …

  1. installed (new) MySql instance version 8.0.11
  2. installed (new) Python version 3.6.5 accessed via “python3″
  3. installed pip 10.0.1 (via downloading get-pip.py then “python get-pip.py”)
  4. installed (Python module) mysql.connector via “pip install mysql-connector-python-rf”

… environmentally, then (got great help) writing Python mysqlpy.py to test MySql database via Python connection code.

Then we (got more great help and) pieced together Python mysqlemployees.py to create the DDL SQL necessary to create the tables needed to support the MySql sample Employees database. To populate those tables we used MySql’s Employees Sample Database webpage (and associated downloads and other webpages). At the end of today’s PDF slideshow presentation, we show some MySql SQL queries of that Employee Sample Database.

We’ll leave you with some pertinent online websites we visited creating today’s blog posting …



Previous relevant Python MySql Circle and Point DataTable Primer Tutorial is shown below.

Python MySql Circle and Point DataTable Primer Tutorial

Python MySql Circle and Point DataTable Primer Tutorial

When we’ve talked about the MySql database in the past, apart from going on and on and on and on and on and on about the wonders of the phpMyAdmin MySql management tool frontend, we’ve normally talked about it regarding its “Fred and Ginger” relationship to PHP. Well, Ginger was famous before Fred came along, and who can forget Fred in the Towering Inferno movie, with no Ginger in sight … mind you, can’t remember if there were any scenes with people eating cashew chicken for lunch in that movie?! My point is, and here’s the thing, MySql can be a database for other languages just as other languages can go off looking for other databases, for example, have a peruse of PostgreSQL PHP Tutorial.

Our new teaming today is, if you haven’t guessed it already, Python and MySql. We set this up locally on our Mac OS X MacBook Pro system, and wanted it to live, and not interfere with our beloved MAMP local Apache/PHP/MySql environment, which panned out to be no issue at all, working with those MySql tables featured in Circle and Point jQuery DataTable Primer Tutorial. More, the difficulties came with installing the MySQLdb Python module necessary to make the Python (version 3) code below work …


#!/usr/bin/python
# Python MySql tester
# RJM Programming
# October, 2017
# Thanks to https://stackoverflow.com/questions/372885/how-do-i-connect-to-a-mysql-database-in-python
import MySQLdb

db = MySQLdb.connect(host="localhost", # your host, usually localhost
user="root", # your username
passwd="root",
unix_socket="/Applications/MAMP/tmp/mysql/mysql.sock",
db="testdb") # name of the data base


# you must create a Cursor object. It will let
# you execute all the queries you need
cur = db.cursor()

# Use all the SQL you like
cur.execute("SELECT * FROM CIRCLE,POINT where originid=pointid")

# print some cells of all the rows
print "radius", "x ", "y"
for row in cur.fetchall():
print row[2], row[4], row[5]

db.close()

… also download with mysql_db.py link … via, and resulting in …


$ python < mysql_db.py
radius x y
99.0 221.0 170.0
55.0 222.0 111.0
$

So, that install on Mac OS X, for us, as suggested at this useful link, thanks, involved Mac OS X Terminal application’s command line commands …


sudo brew install mysql-connector-c
sudo pip install MySQL-python

In our stream of consciousness PDF slideshow we show you this installing and the other tricky bit, that being, the Python code’s MySql connection code, and how we crept up on how to approach that. Along the way you can see phpMyAdmin in action, as the tool to show the structure of the MySql database, and to verify that the Python program outputs agree with the MySql database content.


Previous relevant Circle and Point jQuery DataTable Primer Tutorial is shown below.

Circle and Point jQuery DataTable Primer Tutorial

Circle and Point jQuery DataTable Primer Tutorial

Perhaps you are a reader who has been interested in the “backend” of web application development, traditionally the database side of Information Technology software development. And maybe along the way you were reading when we presented MySql Stored Procedures Primer Tutorial as shown below? Well, today we take its data “thoughts” and funnel that through the brilliant, the stupendous jQuery (Javascript library) DataTable functionality.

For a lot of programmers, we tend to hone in on Data Tables, in a database, as the most latch-able onto-able thing about databases … or maybe that’s just me … anyway, the Data Table is that “thing” in a database consisting of data presented in …

  • columns … to do with the “type” (or types) of data … and …
  • rows … to do with the “order” of data

… like you are probably familiar with regarding spreadsheets … ie. the letters up the top are like “columns” and the “numbers” on the left hand side are like “rows” with respect to what we’re talking about above. As you can tell from this, a spreadsheet worksheet is a lot like a database Data Table.

Continuing that spreadsheet analogy, you spreadsheet enthusiasts probably have seen the concept of multiple worksheets within the one spreadsheet? Well, that is like our scenario today where we have two Data Tables called …

  • Point
  • Circle

… and for both tables we’re going to have these numerical “count” indexes, as is so common in RDBMS work, because computers can sort faster and join things faster with numerical data. The trade off, as for us, if you imagine it, is, that there can be Data Redundancy, or “inefficiency” in that as far as the “Point” Data Table goes, we may have the same (x,y) co-ordinate set existing multiple times, and we’ll define a unique “row” (or record) for both of these, yet, you’d have to agree, that this is, perhaps inefficient and wasteful. The upside, though, is it is not making my head hurt, because there is a one to one relationship between a “Point” (Data Table) row and a “Circle” row, making the Javascript logic we perform, and you can see with circle_point_jquery_datatable.html less involved with what we are doing today. And what is that, pray tell?

We’re going to let the brilliance of jQuery display that aforesaid mentioned data in its inimitable style … such panache! And then we are going to add “row” click event functionality to draw the point or circle of that (Data Table) row be drawn up the top using HTML SVG graphics. You can also have “column” click events, but we choose “row” clicks to be interested in, because on a row click, the whole “.innerHTML” of that row’s (HTML tr) element is accessible in the logic, and so …

  • should you click on a Point row we draw (x,y) with some co-ordinate text … and …
  • should you click on a Circle row we extract the equivalent Point’s (x,y) to be the circle’s SVG (CX,CY) centre point (easily done because of that one to one correspondence we talked about above), and have the radius value in the last “column” cell of the Circle row we are on, enabling everything we need to draw an SVG circle element

Now in all this, we talked about the “one to one correspondence” numerical indexes, but in practice to make this more robust, in case a superfluous “Point” row is deleted by a do-gooder user later down the track, you may have noticed that all along, the second “column” of the Circle (Data Table) (even though called “originid”) points back (ie. is the same value) as the Point table’s first (and index) column (called “pointid”) and these “join” fields (another name for “column” can be “field”) can still gather apples with other proper apples, in that scenario. But today, that is overkill, because there is no “delete” row (or “record”) functionality in our web application today. That web application you can try for yourself with this live run link.


Previous relevant MySql Stored Procedures Primer Tutorial is shown below.

MySql Stored Procedures Primer Tutorial

MySql Stored Procedures Primer Tutorial

Today’s tutorial follows up on phpMyAdmin interface to MySql and PHP Primer Tutorial in that we again use the brilliant phpMyAdmin to oversee the results of some PHP code which uses MySql calls to create tables called POINT and CIRCLE used to store information defining a circle, and then it creates three MySql stored procedures in the database to help add circle data with the single MySql statement that goes CALL AddCircle(x, y, radius); via the use of those stored procedures. Let’s see below what Wikipedia says about Stored Procedures generally.

A stored procedure is a subroutine available to applications that access a relational database system. A stored procedure (sometimes called a proc, sproc, StoPro, StoredProc, sp or SP) is actually stored in the database data dictionary.

Typical use for stored procedures include data validation (integrated into the database) or access control mechanisms. Furthermore, stored procedures can consolidate and centralize logic that was originally implemented in applications. Extensive or complex processing that requires execution of several SQL statements is moved into stored procedures, and all applications call the procedures. One can use nested stored procedures by executing one stored procedure from within another.

Stored procedures are similar to user-defined functions (UDFs). The major difference is that UDFs can be used like any other expression within SQL statements, whereas stored procedures must be invoked using the CALL statement.[1]

Here is some downloadable PHP programming source code which shows the results of the MySql SQL requests made and can be renamed to ourmysqlstoredprocedure.php as required.

Here is some downloadable supervisory PHP programming source code which gathers the MySql SQL requests made and can be renamed to ourmysql_storedprocedure.php as required.

If you want to develop your own live usage (have provided a live usage link here which will not work but you can use if you are a beginner, to get used to mysql errors, which will occur after you hit either button of the link (these errors indicate bad MySql connection details which are the same reason the database dropdown is not full of options), or you can use this link to see the raw MySql SQL involved in piecing this tutorial together) of these two PHP source codes then you could fix up the hard codings for MySql host/username/password up the top of ourmysql_storeprocedure.php (where you may notice that the default host in the code is localhost:8889 which is the default host string for MySql (ie. port 8889 is used) when using a MAMP (Mac laptop) local web server (which uses localhost:8888 as its local “domain name” for http usage)) or you can keep the same code and use a URL like:

[your-domain-name-plus-a-bit-maybe]/ourmysql_storeprocedure.php?host=[your MySql host address]&username=[your MySql username]&password=[your MySql password]&database=[your optional MySql default database name within the looked up list presented]


Previous phpMyAdmin interface to MySql and PHP Primer Tutorial is relevant and shown below.

phpMyAdmin interface to MySql and PHP Primer Tutorial

phpMyAdmin interface to MySql and PHP Primer Tutorial

Transcript:

You never hear much about the data when you hear about great PHP products, but we
all know it is the data that differentiates the quality of the end result.

That is probably because database products like MySql, SqlServer, Oracle SQL, Advantage and Access
are pretty good at what they do, and emphasise reliability rather than flashiness.

MySql and PHP have a great open source interface with phpMyAdmin, which is so good,
you forget that it is not the default MySql administrator’s interface product.

Let’s have a look at this WordPress database and a bit of how it looks, looking
through the prism of phpMyAdmin

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in Operating System, Tutorials, Uncategorized, eLearning | Tagged , , , , , , , , , , , , , , , , , , , , | Leave a comment

HTML Event Disrupters Primer Tutorial

HTML Event Disrupters Primer Tutorial

HTML Event Disrupters Primer Tutorial

Computer Programming has grown up a lot since the earlier languages, my favourite being, for years, FORTRAN, where a GOTO statement would not always be frowned upon, as much as anything because lazy programmers (cough, cough) could justify their “GOTO” fetishes with “well, all the error handling is GOTO anyway … so … there … ngah!”.

But has it grown up all that much? Think of all the “break” and “return” statement possibilities everywhere. The fact is, the optimists will start something off on the quite likely 99% success rate path of coding, and “break”/”return”/”GOTO” code for that other 1% of reality that still needs attention.

HTML event driven programming has its disrupters. We try here not to use them, so much so that even though yours truly loves event driven programming, I’d never, to my recollection, used …

… and used not to know the former’s benefits. You see event.stopPropagation had always been what I’d imagined I’d want, on rare occasions (when I ended up rearranging arrangements so as not to need to “disrupt” in the first place). It stops “parent” HTML elements inheriting “child” event logics that “propagate” (some references use “bubbling”) up through the HTML hierarchy. For a while I’d given “event.preventDefault” those superhuman powers, silly me! But I’m right with it now.

So why the interest? We had a parent table element with loads of onclick logics of interest, yet we introduced a new input type=button that both had …

  • a need to “geographically sit” within the confines of that table … but …
  • that button’s onclick logic represented an optional bit of functionality, and it would have been wrong to also have the other onclick logics fire off when all the user wanted to do was do that optional button logic

To better show you what we mean, we wrote a proof of concept web application called stopPropagation_preventDefault.html that you can try with this live run link.

You can also see this play out at WordPress 4.1.1′s HTML Event Disrupters Primer Tutorial.

If this was interesting you may be interested in this too.

Posted in Event-Driven Programming, Tutorials, eLearning | Tagged , , , , , , , | Leave a comment

MySql Polygon Spatial Relations via Image Map Tutorial

MySql Polygon Spatial Relations via Image Map Tutorial

MySql Polygon Spatial Relations via Image Map Tutorial

It’s “tomorrow” as per …

Continuing the theme of PHP using MySql databases and dealing with Spatial functionality of MySql Stored Procedures Geometry Tutorial, today we establish some PHP to add into a MySql database table as POLYGON data type data, the HTML area coords attribute. Pourquoi? You’ll see more on this tomorrow.

… of yesterday’s MySql Polygon Insert via Image Map Tutorial, and today, we wanted to show you some really great MySql Spatial Relation Functions That Use Object Shapes. Think polygons and thinking geometry and thinking GIS you would want SQL functionality we show today as per …

  • tell whether one polygon CROSSES another polygon
  • tell whether one polygon is DISJOINT relative to another polygon
  • tell whether one polygon EQUALS another polygon in a spatial sense
  • tell whether one polygon INTERSECTS another polygon
  • tell whether one polygon OVERLAPS another polygon
  • tell whether one polygon TOUCHES another polygon
  • tell whether one polygon is WITHIN another polygon

Here is some downloadable supervisory PHP programming source code which gathers the MySql SQL requests made for POLYGON data type INSERT MySql SQL statements and can be renamed to the changed map_area_polygon_mysql.php for your perusal, and which we use incorporated with our local MAMP Apache/PHP/MySql web server, or via this live run link.

Now with the supervised PHP programming source code which gathers the MySql SQL requests made for POLYGON data type INSERT MySql SQL statements and can be renamed to the changed ourmysqlstoredprocedure.php for your perusal.

You can also see this play out at WordPress 4.1.1′s MySql Polygon Spatial Relations via Image Map Tutorial.


Previous relevant MySql Polygon Insert via Image Map Tutorial is shown below.

MySql Polygon Insert via Image Map Tutorial

MySql Polygon Insert via Image Map Tutorial

Continuing the theme of PHP using MySql databases and dealing with Spatial functionality of MySql Stored Procedures Geometry Tutorial, today we establish some PHP to add into a MySql database table as POLYGON data type data, the HTML area coords attribute. Pourquoi? You’ll see more on this tomorrow. Let’s today, just get to insert records, and that looks like, in MySql SQL …

Table Creation

DROP TABLE IF EXISTS POLYGONS;
CREATE TABLE POLYGONS (
polyid INT NOT NULL AUTO_INCREMENT,
mapid VARCHAR(20) NOT NULL,
onepolygon POLYGON NOT NULL,
PRIMARY KEY (polyid));

Insert Statement Examples

INSERT INTO POLYGONS (`mapid`,`onepolygon`) values (‘sh80879′,ST_POLYGONFROMTEXT(‘POLYGON ((190 653, 193 645, 192 641, 191 635, 193 629, 195 623, 192 622, 194 610, 192 606, 186 607, 183 597, 185 593, 181 590, 178 586, 176 580, 172 576, 181 576, 189 574, 198 570, 204 565, 198 562, 202 559, 202 551, 207 550, 214 553, 219 553, 226 546, 232 544, 239 543, 241 539, 248 539, 255 534, 259 535, 259 545, 259 551, 255 558, 250 567, 246 575, 249 580, 249 590, 250 598, 250 604, 242 604, 234 610, 232 619, 229 627, 221 631, 214 637, 211 646, 204 651, 197 656, 191 655, 190 653))’));
INSERT INTO POLYGONS (`mapid`,`onepolygon`) values (‘sh80879′,ST_POLYGONFROMTEXT(‘POLYGON ((190 651, 193 644, 190 638, 193 633, 195 627, 196 622, 191 621, 194 617, 192 611, 193 607, 188 607, 185 606, 184 604, 184 599, 185 594, 181 592, 183 587, 181 585, 176 585, 177 582, 173 580, 172 576, 174 575, 170 569, 164 570, 157 564, 153 556, 149 554, 141 549, 148 564, 152 569, 158 580, 165 590, 167 600, 173 610, 173 619, 175 622, 171 622, 175 632, 180 638, 184 644, 191 652, 190 651))’));

… featuring MySql’s ST_POLYGONFROMTEXT function usage to INSERT POLYGON data into a MySql database table.

Here is some downloadable (so far only) supervisory PHP programming source code which gathers the MySql SQL requests made for POLYGON data type INSERT MySql SQL statements and can be renamed to map_area_polygon_mysql.php for your initial perusal, and which we use incorporated with our local MAMP Apache/PHP/MySql web server, or via this live run link.


Previous relevant MySql Stored Procedures Geometry Tutorial is shown below.

MySql Stored Procedures Geometry Tutorial

MySql Stored Procedures Geometry Tutorial

We’re back from rjmprogramming.com.au domain thoughts at MySql Stored Procedures User Grant Tutorial back to thinking more about where MySql is at these days regarding General Geometry Property Functions.

This series of functions applicable with MySql SQL DML or “Stored Procedures” (given you have a recent enough version of MySql) may be a more efficient approach for an application you write, perhaps avoiding “double handling” … maybe even “triple handling” in the hierarchy…

  • MySql called from PHP (server side code) as a SELECT statement query result set … down to …
  • PHP (calling the MySql) could achieve this too … down to …
  • Javascript (at the client side) could, perhaps, achieve this too

… depending on what, geometry wise, you want to achieve. On our MAMP Apache/PHP/MySql web server incarnation of our MySql series, as you can see with our tutorial picture today using …

  • PHP 7 … and …
  • mysqli_connect() via 5.7.23 – MySQL

… we show …

  • ST_Envelope

    Returns the minimum bounding rectangle (MBR) for the geometry value

    … via pretty obsessive application of MySql CONCAT function (as well as below)

  • ST_Length

    Returns a double-precision number indicating the length of the LineString or MultiLineString value

Generally speaking, we totally recommend finding out more here, because the closer you keep the data to the functionality, the faster will be the applications you write. You’re here because you have decided on MySql as the data source (database) engine. Being as you’ve gone to all that organizational trouble, it would be a shame to not use MySql in a savvy way interfacing to what your data represents, as soon as integrated as possible.

And here is some downloadable supervisory PHP programming source code which gathers the MySql SQL requests made and can be renamed to the changed ourmysql_storedprocedure.php as required.


Previous relevant MySql Stored Procedures User Grant Tutorial is shown below.

MySql Stored Procedures User Grant Tutorial

MySql Stored Procedures User Grant Tutorial

Yesterday’s MySql Stored Procedures Spatial Tutorial was fully functional for what we wanted to cover on our local MAMP Apache/PHP/MySql web server featuring …

  • PHP 7 … and …
  • mysqli_connect() via 5.7.23 – MySQL

… but to offer any version of it “live” on rjmprogramming.com.au domain (which we generally try to do for your “reality of purpose” here at this blog) we came across many issues …

  • PHP 5 … and …
  • mysqli_connect() (ie. now the same, ditching the old mysql_connect() ideas) via 5.1.70-cll – MySQL … as well as …
  • security concerns

Hence yesterday’s trepidation, huh?! But what makes databases like MySql, especially with its brilliant phpMyAdmin GUI interface, that “step up” from other data storage methodologies such as HTTP Cookies or Local Storage or Flat Files is the concept of a “user” … yoo, hoo!

The concept of a “user” with “databases” can then team up with concepts such as …

  • privileges
  • role

… in order to add so much more nuance and organization regarding who handles what computing task. Think blogs, for example, and you can have …

  • administration users (you’ll hear “superuser” references) who can achieve all of the functionalities below, and more … versus …
  • users who just read and never intend to write or comment
  • users who want to write blog postings but need administrator help to delete them
  • users who want to comment

… and various other “roles”. “Privileges” can help the “database” decide on what is allowed by a “user” to happen on the “database”.

Very good and secure “database” brands will start very restrictively, maybe on any database starting out with the one administrator “user”. To nuance from that position we need the “MySql” SQL GRANT command (for allowing, and REVOKE is for the other way around), and we’d like to thank and direct you to the excellent MySql GRANT advice as per …

Grant Permissions to MySQL User
The basic syntax for granting permissions is as follows:

GRANT permission ON database.table TO ‘user’@'localhost’;

Here is a short list of commonly used permissions :

ALL – Allow complete access to a specific database. If a database is not specified, then allow complete access to the entirety of MySQL.
CREATE – Allow a user to create databases and tables.
DELETE – Allow a user to delete rows from a table.
DROP – Allow a user to drop databases and tables.
EXECUTE – Allow a user to execute stored routines.
GRANT OPTION – Allow a user to grant or remove another user’s privileges.
INSERT – Allow a user to insert rows from a table.
SELECT – Allow a user to select data from a database.
SHOW DATABASES- Allow a user to view a list of all databases.
UPDATE – Allow a user to update rows in a table.

Coming back to our MySql “Stored Procedure” thoughts, it’s that “EXECUTE” GRANT above that is needed, and yet on our rjmprogramming.com.au domain web server, that idea was restricted. Hence, behind the scenes we detect this with our PHP, and that we MySql GRANT all the DML SQL (the day to day database populating and updating functionalities) of INSERT and UPDATE and SELECT and DELETE, and break the “Stored Procedures” up into (less cute) sets of DML SQL to achieve the same ends. However, we still present “Stored Procedure” thoughts because …

  • phpMyAdmin (off cPanel (logged in administratively)) will allow you to create the “Stored Procedures”
  • phpMyAdmin (off cPanel (logged in administratively)) will allow you to EXECUTE the copy and pasted “Stored Procedures” CALL (too)

As you can see here, the idea of a database (MySql) “user” can be a friend to your database “security” concerns, wouldn’t you say?


Previous relevant MySql Stored Procedures Spatial Tutorial is shown below.

MySql Stored Procedures Spatial Tutorial

MySql Stored Procedures Spatial Tutorial

Back when we wrote MySql Stored Procedures Primer Tutorial we wrote it more or less to use …

  • PHP 5 and its …
  • mysql_connect()

… MySql database connection logic, but today we have a dual (even trial) purpose in mind (… or “out of mind” if you were naughty and picked some of those mushrooms out and about at the moment (ie. please don’t)) for today’s revisit.

  • get with the plan of using PHP 7 (as we do with our local MAMP Apache/PHP/MySql web server here) along with mysqli_connect … and …
  • start you thinking about MySql’s excellent Spatial Convenience Functions, such as st_distance_sphere() function to determine (in metres) crow fly distances between points (longitude, latitude) on Earth … and …
  • verify that MySql Stored Procedures haven’t changed as far as arrangements go with all this

So, here is some downloadable PHP programming source code which shows the results of the MySql SQL requests made and can be renamed to the changed ourmysqlstoredprocedure.php as required.

And here is some downloadable supervisory PHP programming source code which gathers the MySql SQL requests made and can be renamed to the changed ourmysql_storedprocedure.php as required.

A tad trepidatiously we also offer you today’s live run link that we explain more about regarding restrictiveness and its allowances, tomorrow.

You can also see this play out at WordPress 4.1.1′s MySql Stored Procedures Primer Tutorial.


Previous relevant MySql Stored Procedures Primer Tutorial is shown below.

MySql Stored Procedures Primer Tutorial

MySql Stored Procedures Primer Tutorial

Today’s tutorial follows up on phpMyAdmin interface to MySql and PHP Primer Tutorial in that we again use the brilliant phpMyAdmin to oversee the results of some PHP code which uses MySql calls to create tables called POINT and CIRCLE used to store information defining a circle, and then it creates three MySql stored procedures in the database to help add circle data with the single MySql statement that goes CALL AddCircle(x, y, radius); via the use of those stored procedures. Let’s see below what Wikipedia says about Stored Procedures generally.

A stored procedure is a subroutine available to applications that access a relational database system. A stored procedure (sometimes called a proc, sproc, StoPro, StoredProc, sp or SP) is actually stored in the database data dictionary.

Typical use for stored procedures include data validation (integrated into the database) or access control mechanisms. Furthermore, stored procedures can consolidate and centralize logic that was originally implemented in applications. Extensive or complex processing that requires execution of several SQL statements is moved into stored procedures, and all applications call the procedures. One can use nested stored procedures by executing one stored procedure from within another.

Stored procedures are similar to user-defined functions (UDFs). The major difference is that UDFs can be used like any other expression within SQL statements, whereas stored procedures must be invoked using the CALL statement.[1]

Here is some downloadable PHP programming source code which shows the results of the MySql SQL requests made and can be renamed to ourmysqlstoredprocedure.php as required.

Here is some downloadable supervisory PHP programming source code which gathers the MySql SQL requests made and can be renamed to ourmysql_storedprocedure.php as required.

If you want to develop your own live usage (have provided a live usage link here which will not work but you can use if you are a beginner, to get used to mysql errors, which will occur after you hit either button of the link (these errors indicate bad MySql connection details which are the same reason the database dropdown is not full of options), or you can use this link to see the raw MySql SQL involved in piecing this tutorial together) of these two PHP source codes then you could fix up the hard codings for MySql host/username/password up the top of ourmysql_storeprocedure.php (where you may notice that the default host in the code is localhost:8889 which is the default host string for MySql (ie. port 8889 is used) when using a MAMP (Mac laptop) local web server (which uses localhost:8888 as its local “domain name” for http usage)) or you can keep the same code and use a URL like:

[your-domain-name-plus-a-bit-maybe]/ourmysql_storeprocedure.php?host=[your MySql host address]&username=[your MySql username]&password=[your MySql password]&database=[your optional MySql default database name within the looked up list presented]


Previous phpMyAdmin interface to MySql and PHP Primer Tutorial is relevant and shown below.

phpMyAdmin interface to MySql and PHP Primer Tutorial

phpMyAdmin interface to MySql and PHP Primer Tutorial

Transcript:

You never hear much about the data when you hear about great PHP products, but we
all know it is the data that differentiates the quality of the end result.

That is probably because database products like MySql, SqlServer, Oracle SQL, Advantage and Access
are pretty good at what they do, and emphasise reliability rather than flashiness.

MySql and PHP have a great open source interface with phpMyAdmin, which is so good,
you forget that it is not the default MySql administrator’s interface product.

Let’s have a look at this WordPress database and a bit of how it looks, looking
through the prism of phpMyAdmin

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in Database, Tutorials, eLearning | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

MySql Polygon Insert via Image Map Tutorial

MySql Polygon Insert via Image Map Tutorial

MySql Polygon Insert via Image Map Tutorial

Continuing the theme of PHP using MySql databases and dealing with Spatial functionality of MySql Stored Procedures Geometry Tutorial, today we establish some PHP to add into a MySql database table as POLYGON data type data, the HTML area coords attribute. Pourquoi? You’ll see more on this tomorrow. Let’s today, just get to insert records, and that looks like, in MySql SQL …

Table Creation

DROP TABLE IF EXISTS POLYGONS;
CREATE TABLE POLYGONS (
polyid INT NOT NULL AUTO_INCREMENT,
mapid VARCHAR(20) NOT NULL,
onepolygon POLYGON NOT NULL,
PRIMARY KEY (polyid));

Insert Statement Examples

INSERT INTO POLYGONS (`mapid`,`onepolygon`) values (‘sh80879′,ST_POLYGONFROMTEXT(‘POLYGON ((190 653, 193 645, 192 641, 191 635, 193 629, 195 623, 192 622, 194 610, 192 606, 186 607, 183 597, 185 593, 181 590, 178 586, 176 580, 172 576, 181 576, 189 574, 198 570, 204 565, 198 562, 202 559, 202 551, 207 550, 214 553, 219 553, 226 546, 232 544, 239 543, 241 539, 248 539, 255 534, 259 535, 259 545, 259 551, 255 558, 250 567, 246 575, 249 580, 249 590, 250 598, 250 604, 242 604, 234 610, 232 619, 229 627, 221 631, 214 637, 211 646, 204 651, 197 656, 191 655, 190 653))’));
INSERT INTO POLYGONS (`mapid`,`onepolygon`) values (‘sh80879′,ST_POLYGONFROMTEXT(‘POLYGON ((190 651, 193 644, 190 638, 193 633, 195 627, 196 622, 191 621, 194 617, 192 611, 193 607, 188 607, 185 606, 184 604, 184 599, 185 594, 181 592, 183 587, 181 585, 176 585, 177 582, 173 580, 172 576, 174 575, 170 569, 164 570, 157 564, 153 556, 149 554, 141 549, 148 564, 152 569, 158 580, 165 590, 167 600, 173 610, 173 619, 175 622, 171 622, 175 632, 180 638, 184 644, 191 652, 190 651))’));

… featuring MySql’s ST_POLYGONFROMTEXT function usage to INSERT POLYGON data into a MySql database table.

Here is some downloadable (so far only) supervisory PHP programming source code which gathers the MySql SQL requests made for POLYGON data type INSERT MySql SQL statements and can be renamed to map_area_polygon_mysql.php for your initial perusal, and which we use incorporated with our local MAMP Apache/PHP/MySql web server, or via this live run link.

You can also see this play out at WordPress 4.1.1′s MySql Polygon Insert via Image Map Tutorial.


Previous relevant MySql Stored Procedures Geometry Tutorial is shown below.

MySql Stored Procedures Geometry Tutorial

MySql Stored Procedures Geometry Tutorial

We’re back from rjmprogramming.com.au domain thoughts at MySql Stored Procedures User Grant Tutorial back to thinking more about where MySql is at these days regarding General Geometry Property Functions.

This series of functions applicable with MySql SQL DML or “Stored Procedures” (given you have a recent enough version of MySql) may be a more efficient approach for an application you write, perhaps avoiding “double handling” … maybe even “triple handling” in the hierarchy…

  • MySql called from PHP (server side code) as a SELECT statement query result set … down to …
  • PHP (calling the MySql) could achieve this too … down to …
  • Javascript (at the client side) could, perhaps, achieve this too

… depending on what, geometry wise, you want to achieve. On our MAMP Apache/PHP/MySql web server incarnation of our MySql series, as you can see with our tutorial picture today using …

  • PHP 7 … and …
  • mysqli_connect() via 5.7.23 – MySQL

… we show …

  • ST_Envelope

    Returns the minimum bounding rectangle (MBR) for the geometry value

    … via pretty obsessive application of MySql CONCAT function (as well as below)

  • ST_Length

    Returns a double-precision number indicating the length of the LineString or MultiLineString value

Generally speaking, we totally recommend finding out more here, because the closer you keep the data to the functionality, the faster will be the applications you write. You’re here because you have decided on MySql as the data source (database) engine. Being as you’ve gone to all that organizational trouble, it would be a shame to not use MySql in a savvy way interfacing to what your data represents, as soon as integrated as possible.

And here is some downloadable supervisory PHP programming source code which gathers the MySql SQL requests made and can be renamed to the changed ourmysql_storedprocedure.php as required.


Previous relevant MySql Stored Procedures User Grant Tutorial is shown below.

MySql Stored Procedures User Grant Tutorial

MySql Stored Procedures User Grant Tutorial

Yesterday’s MySql Stored Procedures Spatial Tutorial was fully functional for what we wanted to cover on our local MAMP Apache/PHP/MySql web server featuring …

  • PHP 7 … and …
  • mysqli_connect() via 5.7.23 – MySQL

… but to offer any version of it “live” on rjmprogramming.com.au domain (which we generally try to do for your “reality of purpose” here at this blog) we came across many issues …

  • PHP 5 … and …
  • mysqli_connect() (ie. now the same, ditching the old mysql_connect() ideas) via 5.1.70-cll – MySQL … as well as …
  • security concerns

Hence yesterday’s trepidation, huh?! But what makes databases like MySql, especially with its brilliant phpMyAdmin GUI interface, that “step up” from other data storage methodologies such as HTTP Cookies or Local Storage or Flat Files is the concept of a “user” … yoo, hoo!

The concept of a “user” with “databases” can then team up with concepts such as …

  • privileges
  • role

… in order to add so much more nuance and organization regarding who handles what computing task. Think blogs, for example, and you can have …

  • administration users (you’ll hear “superuser” references) who can achieve all of the functionalities below, and more … versus …
  • users who just read and never intend to write or comment
  • users who want to write blog postings but need administrator help to delete them
  • users who want to comment

… and various other “roles”. “Privileges” can help the “database” decide on what is allowed by a “user” to happen on the “database”.

Very good and secure “database” brands will start very restrictively, maybe on any database starting out with the one administrator “user”. To nuance from that position we need the “MySql” SQL GRANT command (for allowing, and REVOKE is for the other way around), and we’d like to thank and direct you to the excellent MySql GRANT advice as per …

Grant Permissions to MySQL User
The basic syntax for granting permissions is as follows:

GRANT permission ON database.table TO ‘user’@'localhost’;

Here is a short list of commonly used permissions :

ALL – Allow complete access to a specific database. If a database is not specified, then allow complete access to the entirety of MySQL.
CREATE – Allow a user to create databases and tables.
DELETE – Allow a user to delete rows from a table.
DROP – Allow a user to drop databases and tables.
EXECUTE – Allow a user to execute stored routines.
GRANT OPTION – Allow a user to grant or remove another user’s privileges.
INSERT – Allow a user to insert rows from a table.
SELECT – Allow a user to select data from a database.
SHOW DATABASES- Allow a user to view a list of all databases.
UPDATE – Allow a user to update rows in a table.

Coming back to our MySql “Stored Procedure” thoughts, it’s that “EXECUTE” GRANT above that is needed, and yet on our rjmprogramming.com.au domain web server, that idea was restricted. Hence, behind the scenes we detect this with our PHP, and that we MySql GRANT all the DML SQL (the day to day database populating and updating functionalities) of INSERT and UPDATE and SELECT and DELETE, and break the “Stored Procedures” up into (less cute) sets of DML SQL to achieve the same ends. However, we still present “Stored Procedure” thoughts because …

  • phpMyAdmin (off cPanel (logged in administratively)) will allow you to create the “Stored Procedures”
  • phpMyAdmin (off cPanel (logged in administratively)) will allow you to EXECUTE the copy and pasted “Stored Procedures” CALL (too)

As you can see here, the idea of a database (MySql) “user” can be a friend to your database “security” concerns, wouldn’t you say?


Previous relevant MySql Stored Procedures Spatial Tutorial is shown below.

MySql Stored Procedures Spatial Tutorial

MySql Stored Procedures Spatial Tutorial

Back when we wrote MySql Stored Procedures Primer Tutorial we wrote it more or less to use …

  • PHP 5 and its …
  • mysql_connect()

… MySql database connection logic, but today we have a dual (even trial) purpose in mind (… or “out of mind” if you were naughty and picked some of those mushrooms out and about at the moment (ie. please don’t)) for today’s revisit.

  • get with the plan of using PHP 7 (as we do with our local MAMP Apache/PHP/MySql web server here) along with mysqli_connect … and …
  • start you thinking about MySql’s excellent Spatial Convenience Functions, such as st_distance_sphere() function to determine (in metres) crow fly distances between points (longitude, latitude) on Earth … and …
  • verify that MySql Stored Procedures haven’t changed as far as arrangements go with all this

So, here is some downloadable PHP programming source code which shows the results of the MySql SQL requests made and can be renamed to the changed ourmysqlstoredprocedure.php as required.

And here is some downloadable supervisory PHP programming source code which gathers the MySql SQL requests made and can be renamed to the changed ourmysql_storedprocedure.php as required.

A tad trepidatiously we also offer you today’s live run link that we explain more about regarding restrictiveness and its allowances, tomorrow.

You can also see this play out at WordPress 4.1.1′s MySql Stored Procedures Primer Tutorial.


Previous relevant MySql Stored Procedures Primer Tutorial is shown below.

MySql Stored Procedures Primer Tutorial

MySql Stored Procedures Primer Tutorial

Today’s tutorial follows up on phpMyAdmin interface to MySql and PHP Primer Tutorial in that we again use the brilliant phpMyAdmin to oversee the results of some PHP code which uses MySql calls to create tables called POINT and CIRCLE used to store information defining a circle, and then it creates three MySql stored procedures in the database to help add circle data with the single MySql statement that goes CALL AddCircle(x, y, radius); via the use of those stored procedures. Let’s see below what Wikipedia says about Stored Procedures generally.

A stored procedure is a subroutine available to applications that access a relational database system. A stored procedure (sometimes called a proc, sproc, StoPro, StoredProc, sp or SP) is actually stored in the database data dictionary.

Typical use for stored procedures include data validation (integrated into the database) or access control mechanisms. Furthermore, stored procedures can consolidate and centralize logic that was originally implemented in applications. Extensive or complex processing that requires execution of several SQL statements is moved into stored procedures, and all applications call the procedures. One can use nested stored procedures by executing one stored procedure from within another.

Stored procedures are similar to user-defined functions (UDFs). The major difference is that UDFs can be used like any other expression within SQL statements, whereas stored procedures must be invoked using the CALL statement.[1]

Here is some downloadable PHP programming source code which shows the results of the MySql SQL requests made and can be renamed to ourmysqlstoredprocedure.php as required.

Here is some downloadable supervisory PHP programming source code which gathers the MySql SQL requests made and can be renamed to ourmysql_storedprocedure.php as required.

If you want to develop your own live usage (have provided a live usage link here which will not work but you can use if you are a beginner, to get used to mysql errors, which will occur after you hit either button of the link (these errors indicate bad MySql connection details which are the same reason the database dropdown is not full of options), or you can use this link to see the raw MySql SQL involved in piecing this tutorial together) of these two PHP source codes then you could fix up the hard codings for MySql host/username/password up the top of ourmysql_storeprocedure.php (where you may notice that the default host in the code is localhost:8889 which is the default host string for MySql (ie. port 8889 is used) when using a MAMP (Mac laptop) local web server (which uses localhost:8888 as its local “domain name” for http usage)) or you can keep the same code and use a URL like:

[your-domain-name-plus-a-bit-maybe]/ourmysql_storeprocedure.php?host=[your MySql host address]&username=[your MySql username]&password=[your MySql password]&database=[your optional MySql default database name within the looked up list presented]


Previous phpMyAdmin interface to MySql and PHP Primer Tutorial is relevant and shown below.

phpMyAdmin interface to MySql and PHP Primer Tutorial

phpMyAdmin interface to MySql and PHP Primer Tutorial

Transcript:

You never hear much about the data when you hear about great PHP products, but we
all know it is the data that differentiates the quality of the end result.

That is probably because database products like MySql, SqlServer, Oracle SQL, Advantage and Access
are pretty good at what they do, and emphasise reliability rather than flashiness.

MySql and PHP have a great open source interface with phpMyAdmin, which is so good,
you forget that it is not the default MySql administrator’s interface product.

Let’s have a look at this WordPress database and a bit of how it looks, looking
through the prism of phpMyAdmin

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in Database, Tutorials, eLearning | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

MySql Stored Procedures Geometry Tutorial

MySql Stored Procedures Geometry Tutorial

MySql Stored Procedures Geometry Tutorial

We’re back from rjmprogramming.com.au domain thoughts at MySql Stored Procedures User Grant Tutorial back to thinking more about where MySql is at these days regarding General Geometry Property Functions.

This series of functions applicable with MySql SQL DML or “Stored Procedures” (given you have a recent enough version of MySql) may be a more efficient approach for an application you write, perhaps avoiding “double handling” … maybe even “triple handling” in the hierarchy…

  • MySql called from PHP (server side code) as a SELECT statement query result set … down to …
  • PHP (calling the MySql) could achieve this too … down to …
  • Javascript (at the client side) could, perhaps, achieve this too

… depending on what, geometry wise, you want to achieve. On our MAMP Apache/PHP/MySql web server incarnation of our MySql series, as you can see with our tutorial picture today using …

  • PHP 7 … and …
  • mysqli_connect() via 5.7.23 – MySQL

… we show …

  • ST_Envelope

    Returns the minimum bounding rectangle (MBR) for the geometry value

    … via pretty obsessive application of MySql CONCAT function (as well as below)

  • ST_Length

    Returns a double-precision number indicating the length of the LineString or MultiLineString value

Generally speaking, we totally recommend finding out more here, because the closer you keep the data to the functionality, the faster will be the applications you write. You’re here because you have decided on MySql as the data source (database) engine. Being as you’ve gone to all that organizational trouble, it would be a shame to not use MySql in a savvy way interfacing to what your data represents, as soon as integrated as possible.

So, here is some downloadable PHP programming source code which shows the results of the MySql SQL requests made and can be renamed to the changed ourmysqlstoredprocedure.php as required.

And here is some downloadable supervisory PHP programming source code which gathers the MySql SQL requests made and can be renamed to the changed ourmysql_storedprocedure.php as required.

You can also see this play out at WordPress 4.1.1′s MySql Stored Procedures Geometry Tutorial.


Previous relevant MySql Stored Procedures User Grant Tutorial is shown below.

MySql Stored Procedures User Grant Tutorial

MySql Stored Procedures User Grant Tutorial

Yesterday’s MySql Stored Procedures Spatial Tutorial was fully functional for what we wanted to cover on our local MAMP Apache/PHP/MySql web server featuring …

  • PHP 7 … and …
  • mysqli_connect() via 5.7.23 – MySQL

… but to offer any version of it “live” on rjmprogramming.com.au domain (which we generally try to do for your “reality of purpose” here at this blog) we came across many issues …

  • PHP 5 … and …
  • mysqli_connect() (ie. now the same, ditching the old mysql_connect() ideas) via 5.1.70-cll – MySQL … as well as …
  • security concerns

Hence yesterday’s trepidation, huh?! But what makes databases like MySql, especially with its brilliant phpMyAdmin GUI interface, that “step up” from other data storage methodologies such as HTTP Cookies or Local Storage or Flat Files is the concept of a “user” … yoo, hoo!

The concept of a “user” with “databases” can then team up with concepts such as …

  • privileges
  • role

… in order to add so much more nuance and organization regarding who handles what computing task. Think blogs, for example, and you can have …

  • administration users (you’ll hear “superuser” references) who can achieve all of the functionalities below, and more … versus …
  • users who just read and never intend to write or comment
  • users who want to write blog postings but need administrator help to delete them
  • users who want to comment

… and various other “roles”. “Privileges” can help the “database” decide on what is allowed by a “user” to happen on the “database”.

Very good and secure “database” brands will start very restrictively, maybe on any database starting out with the one administrator “user”. To nuance from that position we need the “MySql” SQL GRANT command (for allowing, and REVOKE is for the other way around), and we’d like to thank and direct you to the excellent MySql GRANT advice as per …

Grant Permissions to MySQL User
The basic syntax for granting permissions is as follows:

GRANT permission ON database.table TO ‘user’@'localhost’;

Here is a short list of commonly used permissions :

ALL – Allow complete access to a specific database. If a database is not specified, then allow complete access to the entirety of MySQL.
CREATE – Allow a user to create databases and tables.
DELETE – Allow a user to delete rows from a table.
DROP – Allow a user to drop databases and tables.
EXECUTE – Allow a user to execute stored routines.
GRANT OPTION – Allow a user to grant or remove another user’s privileges.
INSERT – Allow a user to insert rows from a table.
SELECT – Allow a user to select data from a database.
SHOW DATABASES- Allow a user to view a list of all databases.
UPDATE – Allow a user to update rows in a table.

Coming back to our MySql “Stored Procedure” thoughts, it’s that “EXECUTE” GRANT above that is needed, and yet on our rjmprogramming.com.au domain web server, that idea was restricted. Hence, behind the scenes we detect this with our PHP, and that we MySql GRANT all the DML SQL (the day to day database populating and updating functionalities) of INSERT and UPDATE and SELECT and DELETE, and break the “Stored Procedures” up into (less cute) sets of DML SQL to achieve the same ends. However, we still present “Stored Procedure” thoughts because …

  • phpMyAdmin (off cPanel (logged in administratively)) will allow you to create the “Stored Procedures”
  • phpMyAdmin (off cPanel (logged in administratively)) will allow you to EXECUTE the copy and pasted “Stored Procedures” CALL (too)

As you can see here, the idea of a database (MySql) “user” can be a friend to your database “security” concerns, wouldn’t you say?


Previous relevant MySql Stored Procedures Spatial Tutorial is shown below.

MySql Stored Procedures Spatial Tutorial

MySql Stored Procedures Spatial Tutorial

Back when we wrote MySql Stored Procedures Primer Tutorial we wrote it more or less to use …

  • PHP 5 and its …
  • mysql_connect()

… MySql database connection logic, but today we have a dual (even trial) purpose in mind (… or “out of mind” if you were naughty and picked some of those mushrooms out and about at the moment (ie. please don’t)) for today’s revisit.

  • get with the plan of using PHP 7 (as we do with our local MAMP Apache/PHP/MySql web server here) along with mysqli_connect … and …
  • start you thinking about MySql’s excellent Spatial Convenience Functions, such as st_distance_sphere() function to determine (in metres) crow fly distances between points (longitude, latitude) on Earth … and …
  • verify that MySql Stored Procedures haven’t changed as far as arrangements go with all this

So, here is some downloadable PHP programming source code which shows the results of the MySql SQL requests made and can be renamed to the changed ourmysqlstoredprocedure.php as required.

And here is some downloadable supervisory PHP programming source code which gathers the MySql SQL requests made and can be renamed to the changed ourmysql_storedprocedure.php as required.

A tad trepidatiously we also offer you today’s live run link that we explain more about regarding restrictiveness and its allowances, tomorrow.

You can also see this play out at WordPress 4.1.1′s MySql Stored Procedures Primer Tutorial.


Previous relevant MySql Stored Procedures Primer Tutorial is shown below.

MySql Stored Procedures Primer Tutorial

MySql Stored Procedures Primer Tutorial

Today’s tutorial follows up on phpMyAdmin interface to MySql and PHP Primer Tutorial in that we again use the brilliant phpMyAdmin to oversee the results of some PHP code which uses MySql calls to create tables called POINT and CIRCLE used to store information defining a circle, and then it creates three MySql stored procedures in the database to help add circle data with the single MySql statement that goes CALL AddCircle(x, y, radius); via the use of those stored procedures. Let’s see below what Wikipedia says about Stored Procedures generally.

A stored procedure is a subroutine available to applications that access a relational database system. A stored procedure (sometimes called a proc, sproc, StoPro, StoredProc, sp or SP) is actually stored in the database data dictionary.

Typical use for stored procedures include data validation (integrated into the database) or access control mechanisms. Furthermore, stored procedures can consolidate and centralize logic that was originally implemented in applications. Extensive or complex processing that requires execution of several SQL statements is moved into stored procedures, and all applications call the procedures. One can use nested stored procedures by executing one stored procedure from within another.

Stored procedures are similar to user-defined functions (UDFs). The major difference is that UDFs can be used like any other expression within SQL statements, whereas stored procedures must be invoked using the CALL statement.[1]

Here is some downloadable PHP programming source code which shows the results of the MySql SQL requests made and can be renamed to ourmysqlstoredprocedure.php as required.

Here is some downloadable supervisory PHP programming source code which gathers the MySql SQL requests made and can be renamed to ourmysql_storedprocedure.php as required.

If you want to develop your own live usage (have provided a live usage link here which will not work but you can use if you are a beginner, to get used to mysql errors, which will occur after you hit either button of the link (these errors indicate bad MySql connection details which are the same reason the database dropdown is not full of options), or you can use this link to see the raw MySql SQL involved in piecing this tutorial together) of these two PHP source codes then you could fix up the hard codings for MySql host/username/password up the top of ourmysql_storeprocedure.php (where you may notice that the default host in the code is localhost:8889 which is the default host string for MySql (ie. port 8889 is used) when using a MAMP (Mac laptop) local web server (which uses localhost:8888 as its local “domain name” for http usage)) or you can keep the same code and use a URL like:

[your-domain-name-plus-a-bit-maybe]/ourmysql_storeprocedure.php?host=[your MySql host address]&username=[your MySql username]&password=[your MySql password]&database=[your optional MySql default database name within the looked up list presented]


Previous phpMyAdmin interface to MySql and PHP Primer Tutorial is relevant and shown below.

phpMyAdmin interface to MySql and PHP Primer Tutorial

phpMyAdmin interface to MySql and PHP Primer Tutorial

Transcript:

You never hear much about the data when you hear about great PHP products, but we
all know it is the data that differentiates the quality of the end result.

That is probably because database products like MySql, SqlServer, Oracle SQL, Advantage and Access
are pretty good at what they do, and emphasise reliability rather than flashiness.

MySql and PHP have a great open source interface with phpMyAdmin, which is so good,
you forget that it is not the default MySql administrator’s interface product.

Let’s have a look at this WordPress database and a bit of how it looks, looking
through the prism of phpMyAdmin

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

Posted in Database, Tutorials, eLearning | Tagged , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment