Skip to main content
MPCC
Back to Website
Enter your search query
You are currently using guest access (
Log in
)
PHP/MySQL Course
Home
Courses
Miscellaneous
MoodleShare Archive
MoodleShare Technology
PHP/MySQL
Topic 5
Program interface to MySQL from PHP ($$$)
Program interface to MySQL from PHP ($$$)
You have answered 0 correctly out of 1 attempts.
Read pages 361 to 365 about opening a DB and creating a table.
Notes:
the new mysqli_connect( ) creates a object that represents the connection, if called with the first three arguments only, it just connects to the mySQL server without a specific DB, if called with four arguments, you supply the DB name to use in the fourth argument. The first argument can be the value null to indicate that you are connecting to the server as localhost.
Here is example code to connect to the mySQL server and create a db named testDB:
<?
$conn = new mysqli( NULL, "
username
", "
password
"); // conn to mysql with localhost
if (mysqli_connect_errno()) {
printf("Connection failed: %s\n", mysqli_connect_error());
exit();
} else {
$sql = "CREATE DATABASE testDB;"
$result = mysql_query($conn, $sql);
if($result == TRUE) {
echo "DB: testDB has been created";
} else {
printf("DB create failed: %s\n", mysqli_error());
}
}
mysqli_close($conn);
?>
Question?
In the code on page 364, what value will $res have if the table could not be created because of an error?
Your answer
◄ Lab: Writing SQL statements
Jump to...
Jump to...
Read Me First - Orientation
Syllabus
Welcome Video
GJenkins Video Library (PHP/MySQL Class)
PHP language reference documentation
Installing the software for the course
Accessing your Web Server
W3Schools tutorials (excelent reference)
KillerPHP.com Video Library (great extra material)
News forum
Student forum - a place for students to talk to each other
Download a Copy of this Course
Instructor comments on Chapter 1
Base Level Learning Outcomes Survey ($$$)
Basic HTML ($$$)
CSS Lesson ($$$)
Assignment: Create and publish your first web file ($$$)
Using PHP program ($$$)
your base php page
Assignment: Publish your PHP program ($$$)
Assignment: create a new PHP program ($$$)
Topic 1 Quiz ($$$)
variables and data types ($$$)
Play KillerPHP.com video on creating variables
Play KillerPHP.com video on print and variable expansion
Assignment: Chapter 5 variables ($$$)
Assignment: variables activity ($$$)
Assignment: comparisons activity ($$$)
Flow Control ($$$)
Assignment: color table ($$$)
Assignment: Day of the Weeks ($$$)
functions ($$$)
Video on calling functions (step by step explained)
Assigment: createTable4
Topic 2 Quiz ($$$)
Arrays ($$$)
Assignment: Deal Cards ($$$)
Objected Oriented PHP (OOP)
Video: Example of creating and using classes (Card Deck)
Assignment: Class Deck ($$$)
Strings,Dates, and Times ($$$)
PHP Forms ($$$)
Assignment: Guessing Game ($$$)
Assignment: Birthday ($$$)
Assignment: Chuck-a-luck ($$$)
Topic 3 Quiz ($$$)
** Link to topic 3 videos
Play this video about file paths in PHP
Uploading Files ($$$)
Program to upload Picture ($$$)
About State and Stateless web pages
Cookies ($$$)
Sessions ($$$)
Assignment: Guessing Game 2 ($$$)
using files ($$$)
Assignment: Visitor count ($$$)
Assignment: Working with Images ($$$)
Topic 4 Quiz ($$$)
NOTE: how to set file/folder permissions
Understanding Databases
MySQL Basic Data Types and CREATE TABLE ($$$)
Building a database from the command line (READ and VIEW)
Program: Build a DB using SSH ($$$)
Basic SQL Commands ($$$)
Play this video introducing phpMyAdmin
Play this video on how to create a DB in phpMyAdmin and enter data
Program: Create a Database design
Project: Import two databases
Lab: Writing SQL statements
CRUD basics
Program: Contacts
About your final project
Mailing List ($$$)
Address Book ($$$)
Discussion Forum ($$$)
Store Front / Shopping Cart ($$$)
Calendar ($$$)
Extra Credit Survey ($$$)
CRUD basics ►