This video will discuss how to connect to MySQL with PHP. I'm using PhpMyAdmin and connect MySQL database with PHP using the WAMP server. And you can use this code any php server.
. . . WampServer Version 3.1.9 64bit Created by Romain Bourdon (2005) Maintainer / Upgrade to 2.5 by Herve Leclerc Upgrade to 3 by Otomatic (wampserver@otomatic.net) Multi styles for homepage by Jojaba Installer by Inno Setup: http://www.jrsoftware.org/isinfo.php Forum Wampserver: http://forum.wampserver.com/index.php ______________________ Versions used ______________________ Apache 2.4.39 Port 80- PHP 7.2.18 MySQL 5.7.26 Port 3308 PHP 5.6.40 for CLI (Command-Line Interface)CODE:-
<?php//DB connection// new mysqli(host, user, password, database name);$connect = new mysqli("localhost:3308", "bit", "bitbyte", "bit_yt");//Check connectionif($connect->connect_error){echo "Failed to connect to MySQL: ". $connect->connect_error;exit();}//query$sql = "SELECT * FROM students LIMIT 1";$sql_connect = $connect->query($sql);$getResult = mysqli_fetch_array($sql_connect, MYSQLI_ASSOC);//outputprint_r($getResult);
Comments
Post a Comment