Connecting to MySQL database

I would like some assistance with php script cor connecting to my database…currently I have the following:
$user = ‘epiz_258xxxxx’;
$password = ‘xxxxx’;
$db = ‘epiz_25816190_database_name’;
$host = ‘sql303.epizy.com’;

$dbc = mysqli_connect($host, $user, $password, $db);

<> then
$r = mysqli_query($dbc, $q);

HELP Please. Just learning this…ThNK YOU.

Sure, what’s problem?

$q = “INSERT INTO list (idno, fname, lname, country, status, email)VALUES (‘$idno’, ‘$fname’, ‘$lname’, ‘$country’, ‘$status’, ‘$email’)”;
$r = mysqli_query($dbc, $q);

Using the above…my values are not being inserted into the table so it leaves me to think I have a connection issue.

It should be quite easy to find out. Both the mysqli_connect and mysqli_query function return false if the functions are unsuccessful. If that happens, you can use the functions mysqli_connect_error or mysqli_error to retrieve the actual error message.

Can you add error checks to your code and see if they return any errors and error messages? That way, you don’t have to think that it may be a connection issue: you will know for sure whether you have a connection issue and what the issue is.

2 Likes

I’ve found the bugs…my new problem is this message “Unable to select database”. I think I have the database name correct because I copied and paste it from here. Can you assist? Thanks.

I don’t know about the message, but a simple Google search lead me to this post which tells more about it:

If you are still unable to connect after applying the fix from that post, you may want to search the web yourself for the next error message. If it’s a code error, you can probably find a post already which tells you how to fix it. That’s a lot faster than having to wait for a reply on here.

3 Likes

Excuse-me,
I would like someone to help me. I’m only a beginner.
This is the beginning of my code

<?php

/* Récupération des informations du formulaire*/

if (isset($_POST['nom']) && isset($_POST['telephone']) && isset($_POST['mail']) && isset($_POST['message'])) {

$nom = trim($_POST['nom']);

$telephone = trim($_POST['telephone']);

$mail = trim($_POST['mail']);

$message = trim($_POST['message']);

echo 'Cher '.$nom.', nous vous remercions d avoir pris intérêt à notre entreprise, mais malheureusement le serveur auquel vous avez envoyé ce message est en maintenance. Nous vous enverrons une notification au '.$telephone.'et un e-mail à l adresse suivante :'.$mail.' dès que le serveur sera de nouveau en service. Pour indication, voici le message que vous nous avez envoyé : "'.$message.'".';

This works but then I would like to create a database and keep my values in it, but I do not know anything about how to do it. I’ve search for hours but I’ve never understand what I red.
Hope you can help me…
Thanks by advance.

so you want to store all the values in a database like MySqli

@charlotte

Please create a new topic and do not hijack this post.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.