How can i to connect with mysql? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How can i to connect with mysql?

I need to do a formas using mysql

18th Oct 2016, 3:05 AM
Martell Daniel
Martell Daniel - avatar
2 Answers
+ 1
make a new php file like this : <?php $connectionDB = array( 'IPaddress' => 'the ip address where your database is located', 'user' => 'root or whatever you want to access the database', 'password' => 'the database password', 'DBname => 'the name of the db You want to use' ); $ODBCconnection = @mysqli_connect ($ODBCconnection['IPaddress'], $ODBCconnection['user'], $ODBCconnect['password'], $ODBCconnect['DBname'] ); if (!$ODBCconnection){ echo "Can't connect to the database, try latter."; die(); } and then include it in every page that you need to make a database connection.
18th Oct 2016, 4:58 AM
Fabricio Bertani
Fabricio Bertani - avatar
+ 1
<?php define ('HOST','localhost'); define ('USER','Write your user name here'); define ('PASS','Write your pass word here'); define ('DTBS','Write your Database here'); $dbs_handle=@mysqli_connect(HOST,USER,PASS,DTBS); if (!$dbs_handle) @return Print('Can not connect to the database.'); # and then include it in every page that you need to make a database connection. ?>
18th Oct 2016, 2:46 PM
Hussein Hallafi
Hussein Hallafi - avatar