I want to echo or print content from a database in my terminal on my raspberry pi. I installed MySql client and PHP5. I want to run a php file in my terminal so i created a file:
<?php
$con = mysqli_connect("mysql51-025.wc1","username","password","dbname")
//first one is hostname
if(mysqli_connect_errno()){
echo "failed to connect with error: ". mysqli_connect_error();
}
?>
When i run this in my terminal on my raspberrypi
pi@raspberrypi ~ $ php database.php
I'll get this returned:
PHP warning: mysqli_connect(): (hy000/2005): Unknown MySQL server host 'nameofmyhostinphpfile' (25) in /home/pi/database.php on line 8 failed to connect with error: Unknown MySql server host 'hostname'
My question is how i can make this connection work. And will i be able to execute queries and echo or print those results on my pi and use those results in shell scripts?
Thank you!