| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | --- | 
					
						
							|  |  |  | title: Working With Databases | 
					
						
							|  |  |  | --- | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ## What options are available for PHP to connect to a database?
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-26 16:50:19 -06:00
										 |  |  | PHP can connect to a variety of different databases including MongoDB, MS SQL and MySQL. | 
					
						
							| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | Both PHP and MySQL are very popular and provide an easy, free and open source websites  | 
					
						
							|  |  |  | to be created and are often found together to produce websites of all types.  | 
					
						
							|  |  |  | Both PHP and MySQL can scale to support large numbers of users. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PHP even supports more than one way to deal with connections to MySQL including MySQLi Procedural,  | 
					
						
							|  |  |  | PHP Data Objects (PDO) and MySQLi Object Orientated along with the now deprecated MySQL Connect.  | 
					
						
							|  |  |  | With PHP there are many features built into the core functionality of the language that make links to a  | 
					
						
							|  |  |  | database simple and easy. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Some Examples from Mysqli are- | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-26 17:13:14 -06:00
										 |  |  | ```php | 
					
						
							| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | $con=mysqli_connect("localhost","root","","db_name") or die("Invalid User or Password...cannot connect"); | 
					
						
							| 
									
										
										
										
											2018-12-26 17:13:14 -06:00
										 |  |  | ``` | 
					
						
							|  |  |  | Here we are connecting to a database on the phpmyadmin structure, with no password, and database named `db_name`. |