Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact

Well House Consultants
You are on the site of Well House Consultants who provide Open Source Training Courses and business hotel accommodation. You are welcome to browse and use our resources subject to our copyright statement and to add in links from your pages to ours.
Other subject areas - resources
Java Resources
Well House Manor Resources
Perl Resources
Python Resources
PHP Resources
Object Orientation and General topics
MySQL Resources
Linux / LAMP / Tomcat Resources
Well House Consultants Resources
Extras Resources
C and C++ Resources
Ruby Resources
Tcl/Tk Resources
Web and Intranet Resources
PHP module H113
Using MySQL Databases in PHP Pages
Exercises, examples and other material relating to training module H113. This topic is presented on public courses Learning to program in PHP, PHP Programming, MySQL, PHP Programming, Learning to program in PHP

This module teaches you some of the PHP functions that let you connect to a MySQL database. It also tells you how to write PHP code that can be used on data held in other relational databases without the need to duplicate or rewrite large amounts of code.

Related technical and longer articles
MySQL version 5, PHP version 5 and mysqli
MySQL and PHP - enquiry tool for ad-hoc requirements
Interfacing applications to a MySQL database engine

Articles and tips on this subjectupdated
4483Moving from mysql to mysqli - simple worked example
We have a big codebase of PHP code that uses MySQL databases, much of it written using mysql_ functions which were not object orineted in nature, and have been paralleled by the more recent mysqli_ functions and methods for quite some time now. The older mysql library is now deprecated, with warnings ...
4378What FGW passengers want to talk about / and PHP programming to find out
Much of my recent talk and examples on this blog recently have stressed robust, tested, re-usable code, and that's vital in the majority of applications. However, there are occasions where a "one-off" is needed such as this morning when I wanted to list the most popular subjects covered on our First ...
1561Uploading to a MySQL database through PHP - examples and common questions
One of the most popular pages on the technical part of our web site relates to the uploading of images to a server from a local disc file via a browser, then storing those images on a database, and displaying them later. Another popular page relates to the same thing with .pdf file - and really the ...
3455MySQL, MySQLi, PDO or something else - how best to talk to databases from PHP
One of the consideration that users of Open Source programming languages have make is which one of many ways to do any particular task. Open Source tends to result in lots of very clever facilities being provided, many of which overlap in their use, and many modules being provided via libraries such ...
3035How to display information from a database within a web page
Are you displaying data that's held in an SQL database from within your own PHP program for the first time? Perhaps you have access to a database that's setup / implemented through a standard open source application such as phpBB, the Simple Machines Forum, or Movable Type or be a colleague? Here ...
2432Using print_r in PHP to explore mysql database requests
The print_r function in PHP lets you "print raw" the contents of a variable - great for debugging and far better that print which - if you pass it an array helpfully says Array Embed your print_r into <pre> to </pre> tags ... so that you get a good display on your browser ... otherwise you'll ...
2628An example of an injection attack using Javascript
Delegates sometimes ask me what an "injection attack" is, and for examples. I came across a really good example this morning on (oops!) one of our own pages - it's now fixed, but I'm documenting here and showing you what was happening so that you can learn from it. Visiting one of the most popular pages ...
2561The future of MySQL
MySQL has grown from a very neat little open source database 10 years ago into a very powerful and widespread database that's not always fully open source any longer today. The MySQL company was bought out by Sun a couple of years back (January 2008), and in turn Oracle are now buying Sun. This deal ...
2447MySQL stored procedures / their use on the web from PHP
Are there times when your PHP will pull a large result set back from MySQL, or have to make a large number of queries, just to further process the data into a relatively small dynamic section of a report? If so, why not have the MySQL do more of the work and return a much shorter, more processes results ...
2320Helping new arrivals find out about source code examples
On 30th July, nearly 5300 people arrived at source code examples on our web site from Google searches, from 4000 unique IP addresses. How do I know that? From analysing our log files: -bash-3.2$ grep 'GET \/resources\/ex\.php.*\.google\.' ac_20090730 | grep -v Googlebot | wc 5382 129055 1832168 -bash-3.2$ ...
2259Grouping rows for a summary report - MySQL and PHP
It's quite quick and easy to write a loop that goes through a mysql result set and displays the content on an HTML page (but remember security of data, size of resulting HTML page, and the need to consider special characters such as <). But what if you want a shorter report, grouping records together ...
2071Setting up a MySQL database from PHP
Yes ... training on a Sunday ;-) ... I've been setting up a MySQL database from a PHP script and testing it. A couple of bits of source to share. 1. The setup of the database: <?php mysql_connect("localhost","womble","wimbledon"); mysql_query("create database gerald"); mysql_select_db("gerald"); mysql_query("create ...
1983Keeping PHP code in database and running it
The software for these articles lets me enter HTML and keeps it in a database. If I want to add PHP, that gave me a problem as the data (HTML) was simply read from the database and passed to my client's browser without being parsed for <?php to ?> sections. But problem solved in two different ...
1010Dates, times, clickable diarys in PHP
It's that quiet week between Christmas and the New Year that's an excellent chance to catch up - a little - on some of the things that are important but have been abandoned in the mad rush of urgent things these last 9 months. Like writing a booking system and like - I hope - spending long overdue ...
104mysql_connect or mysql_pconnect in PHP?
If you're connecting to a MySQL database in your PHP application, you'll find that there are two alternative connections - mysql_connect which establishes a new connection "each time" and mysql_pconnect which uses persistent connections. Which should you use? Mysql_connect opens a new connection each ...
937Display an image from a MySQL database in a web page via PHP
There's lots of clever scripts around to tell you how to get images in and out of databases, but nothing simple to show you the principles of including such an image via (say) PHP in a web page. So here goes. you need TWO URLs - you need the HTML page that's going to contain the image, AND you need ...
581Saving a MySQL query results to your local disc for Excel
Do you want to run a database query on a remote server and save the results into a text file on your LOCAL disc - i.e. the disc of the computer at which you're seated and not the disc of the server that's in a remote location? It's not as easy as you think it should be. Because of the security risks ...
947What is an SQL injection attack?
An SQL injection attack is where a user of your form enters a piece of SQL code into it, and wraps it in special characters in such a way that the data entered doesn't get used for the purpose you had intended - it gets used to corrupt or destroy your database. For example, if your form returns to $_REQUEST[message] ...
915Paging through hundreds of entries
I can display all the entries in a table on a single page if there are 10 or 20 of them. When I get up to about 30 or 40 entries, it's getting out of hand ... and with hundreds of entries, I REALLY need a paging system. Quite commonly, I see requests for "paging systems" to meet such requirements and, ...
515MySQL - an FAQ
We're becoming a serious MySQL resource, with many technical articles, examples, forum posts and blog entries answering those difficult-to-resolve issues you may have come across. You might like to bookmark (or link to) this page. Eleven recent articles on MySQL ... Flashbulb moments - facts that ...
666Database design - get it right from first principles
It's VITAL to get your data(base) design more or less right before you write too much code - otherwise you'll end up wasting a lot of time and effort writing kludge code and - worse - forcing your users into work-arounds for the lifetime of the system at great expense to everyone in time, effort and ...
723Viewing images held in a MySQL database via PHP
LOTS of questions on this at the moment. We have a couple of sample scripts that do it - have a look at: * feeder.php which adds images into a database if they've been uploaded as plain text files, displays them from the database if that's where they are already, and generates a rather more informative ...
Examples from our training material
agents.php   Joining MySQL database and searching results in PHP
aos.php   Save a MySQL result set to the local machine
approach.php   Relational Databases - Comparison of approaches
bookstats.php   PHP to front a MySQL multiway join
generic.php   Display a MySQL table, summarising rows
ild.php   mysqli - database to csv example
ildi.php   mysqli - database to csv example
mqchunks.php   Pagination through a database - PHP and MySQL
mqclim.php   searching and paging through results
mysql_joins.php   Showing Joined tables on a web page
people.php   Simple database lookup - using MySQL from PHP
pic_alog.php   view images stored in a MySQL database via PHP
pic_up.php   Uploading an image from a form to a MySQL database via PHP
picclim.php   Search a database of images
picscript.php   Retrieve an image from a database and display it
sekiy.php   Converts data into MySQL commands
select1.php   Selecting information from a database table - unchecked
select2.php   Selecting information from a database table - fully validated
showtowns.php   First steps on looking up data in an existing database on a web page
sort_sql.php   Using an array to sort records off a database
sqd.php   Algorithm selection of where clauses
sql_image_store.html   Web page to call up an image held in an SQL database
sqladd.php   Add information to a database table
sqlcreate.php   Create a MySQL table from a PHP page
sqldelete.php   deleting a database table from PHP
sqlhelper.inc   PHP helper - make up a where clause element
sqlreport.php   report on information held in a relational database
sqltab.php   Full navigation around an SQL database from PHP
yikes.php   Downloading complete database via a PHP script
Public PHP course - a student completes a practical
Public PHP course, Melksham
Background information
Some modules are available for download as a sample of our material or under an Open Training Notes License for free download from http://www.training-notes.co.uk.
Topics covered in this module
Database structure.
How to create a new table.
Adding information to a table.
Selecting information from a table and reporting it to a web page.
Deleting a table.
User input checking and other testing.
Example: A PHP script to select and view the data in any table.
Downloading all the tables from a database.
Uploading tables from a flat text file.
Using other relational databases from PHP.
Using Oracle 8.x and 9.x.
Using the Oracle OCI9 API.
Portable database connection.
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule page.

Well House Consultants specialise in training courses in Python, Perl, PHP, and MySQL. We run Private Courses throughout the UK (and beyond for longer courses), and Public Courses at our training centre in Melksham, Wiltshire, England. It's surprisingly cost effective to come on our public courses - even if you live in a different country or continent to us.

We have a technical library of over 700 books on the subjects on which we teach. These books are available for reference at our training centre. Also available is the Opentalk Forum for discussion of technical questions.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2015: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/resources/H113.html • PAGE BUILT: Thu Sep 18 11:03:17 2014 • BUILD SYSTEM: WomanWithCat