4
I’m having trouble creating the database, on the net I found little content on, I only find how to build database by phpMyAdmin, but it is via script that I want to create.
I have the following code:
<?php
$mysqli = new mysqli("localhost","root","");
if($mysqli-> connect_error){
echo "Não foi possível conectar.";
}
$create_db = "CREATE DATABASE 'my_db'";
if($mysqli->query($create_db)){
echo "conexão bem sucedida";
}
else{
echo "falha na conexão";
}
?>
Wampserver does not point out syntax errors. I always have the answer "connection failure", which is wrong?
You will actually access as a user
rootand no password? This is therootdefault? Does he really have the privilege to do anything in Mysql? Thismy_dbdoes not exist? Tried to change the'for\``? Você entende que aparececonnection failureporque você mandou escrever quando a operação dá um erro? Então precisa ver qual o erro. Já experimentou usarmysqli::$error` to see what error message Mysql is returning?– Maniero
Don’t worry about it! If you use charset=utf-8 on your page, even if in the database the accents do not appear on the page you call the data will appear the accents. Try to enter the data in the same way always so as not to give conflict. If by form always by form.
– user20166