Hello, in this video, we are going to look at creating a database using, you know, a query inside of PHP because before we initially created the database in PHP myadmin created the table either via a query in our PHP code or via the PHP myadmin panel. But there may come a time where you may want to create a new database via code. And to do that pretty simple in the connection instead of doing host server name and then you know, the database name. We don't even know the database name because we technically haven't, you know, connected to it yet. So you get rid of that aspect of it. Leave everything else the same.
And what we want to do now is dolla nection. Oh, you know, we need to do so, we read equals dollar connection. And we'll prepare a query. This query is just create data database and the database name. So I'm gonna say what is curl on court epic database, I'm literally going to use that names aren't gonna say test dB, make sure that haven't been called I've got test but that don't matter. And now we just run it the way we normally would.
And you just run it via secure, you can just run it by the x EC function directly on here, because it's should we return we want to keep it you know, in a similar fashion and if it the way I generally do it, okay, so if I reload that connection successful, and reload the page, we get testdb. There we go. Obviously, there are no tables. The next step either in code, or in the PHP myadmin panel would be to create tables and fill it out, but that is how you create a database using code. If you have any questions, feel free to drop me a message and as usual, I look forward to seeing you in the next video.