From the course: Database Foundations: Application Development
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Use PHP variables
From the course: Database Foundations: Application Development
Use PHP variables
- [Instructor] We can make use of PHP variables to help us reuse elements in our code. PHP variables all start with a dollar sign and then you can give them a unique name. Let's scroll down on our script page here down to script number two and take a look. Now in this example, we're going to add a table to the database that we just created. We need to perform similar tasks as before. First, we're going to connect to the database server and then send it a query, but we can use variables to hold the details of our PostgreSQL functions. First, I'm going to create a new variable called DB Connection. The name here starts with the dollar side. That's how I know that it's a PHP variable. Then, I can set its value to the PG Connect function followed by all of these parameters. We're connecting to the same server using the same port and the same username and password as before. The only difference here is that this time…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
What is PHP and Apache?2m 55s
-
Create a PHP web server10m 58s
-
(Locked)
Connect to the PHP server3m 37s
-
PostgreSQL functions4m 55s
-
(Locked)
Use PHP variables3m 4s
-
(Locked)
Use if/else to handle errors4m 53s
-
(Locked)
Add data to a database4m 7s
-
(Locked)
Format SELECT query results6m 24s
-
(Locked)
Filter results with form controls5m 40s
-
(Locked)
Add data to a table with form controls5m 29s
-
(Locked)
-
-