Connecting MYSQL Databe in php

`<?php
$hostname = “sql304.epizy.com”;
$username = “epiz_22168792”;
$password = “6234662346”;
$database = “epiz_22168792”;

//connection to the database

$conn = mysqli_connect($hostname, $username, $password, $database);

// Check connection

if ($conn->connect_error)
{

die("Connection failed: " . $conn->connect_error);

}

echo “Connected successfully”;
?>`

The Code I used is this. saved it as config.php

But still failed to connect with the data base.
Please help me to conncet with database.

this is index.php link https://bit.ly/2BILGGi

First of all, I forcefully reset your password. Never share your password with anyone, and definitely don’t post your password to a public place like a forum. You are free to change the password again, but don’t change it back to this password, as it’s no longer secure.

Also, I would like to check the script on your account, but I can’t find this script on your account.

@Admin said:
First of all, I forcefully reset your password. Never share your password with anyone, and definitely don’t post your password to a public place like a forum. You are free to change the password again, but don’t change it back to this password, as it’s no longer secure.

Also, I would like to check the script on your account, but I can’t find this script on your account.

I already changed pasword… Before you do… But I am so greatfull to you for asureing my security. ?

You can find the file in the following directory /t.textile.cf/htdocs/b/

@nafio23 said:
You can find the file in the following directory /t.textile.cf/htdocs/b/

Thank you for clarifying. I checked the page, but it for me it just responds with a blank page with a HTTP 500 status code. This means the code is crashing, which is not necessarily caused by a database connectivity issue. https://infinityfree.net/support/http-error-500/

@Admin said:

@nafio23 said:
You can find the file in the following directory /t.textile.cf/htdocs/b/

Thank you for clarifying. I checked the page, but it for me it just responds with a blank page with a HTTP 500 status code. This means the code is crashing, which is not necessarily caused by a database connectivity issue. https://infinityfree.net/support/http-error-500/

Thanks for the help I will be working on that

Sir, I am pretty sure there are missing commas throughout the define declaration.

The correct syntax would be:
define("forPhp","this is the content");

And this double quote is quote… But double. Not single quote that comes twice.

@Admin Close it please .

Why don’t you just post the code here and censor all sensitive information instead? That would pretty much be helpful, since this was (and always be) community forum.

The error is Parse error: syntax error, unexpected ‘sql304’ (T_STRING), expecting ‘,’ or ')

How can I fix this?

Following is the code

`<?php
/* host mysql /
define(‘DBHOST’sql304.epizy.com’');
/
database mysql /
define(‘DBNAME’epiz_11111’');
/
user connect mysql /
define(‘DBUSER’epiz_1111111’');
/
password connect mysql */
define(‘DBPASS’xxxxxx’');

?>`

That’s saved as config.php
**Where is the mistake?? **

I failed to find the solution in the forum.

In think and checked the code again and agin .
although its showing errors .
@Admin Can you check the config.php in the /t.textile.cf/a/config.php

First of all, I merged your three most recent topics. There were different topics about getting the same script to work. I’m all for having one issue per topic, but when one question is clearly a followup question to another, it usually makes more sense to have them all in the same thread.

As for the issue you have now, your config.php looks fine but your common.php (which actually establishes the database connection) does not. In it, I see you’re trying to establish a database connection like this:

@mysql_select_db(’epiz_22168792_1’);

I see you’re using backticks for the start and end of the string. I don’t think those are valid string delimiters. You can use single quotes ' or double quotes " to delimit strings, but not backticks.

Also, you do have a config.php file, but you don’t seem to actually use the values from the config file, and just hard coded them into the common.php file.

Finally, I’m slightly worried about the excessive use of the @ operator. Not showing error messages to prevent leaking sensitive information is a good thing, but ignoring them all together often makes it hard to diagnose issues.

@Admin said:
First of all, I merged your three most recent topics. There were different topics about getting the same script to work. I’m all for having one issue per topic, but when one question is clearly a followup question to another, it usually makes more sense to have them all in the same thread.

As for the issue you have now, your config.php looks fine but your common.php (which actually establishes the database connection) does not. In it, I see you’re trying to establish a database connection like this:

@mysql_select_db(’epiz_22168792_1’);

I see you’re using backticks for the start and end of the string. I don’t think those are valid string delimiters. You can use single quotes ' or double quotes " to delimit strings, but not backticks.

Also, you do have a config.php file, but you don’t seem to actually use the values from the config file, and just hard coded them into the common.php file.

Finally, I’m slightly worried about the excessive use of the @ operator. Not showing error messages to prevent leaking sensitive information is a good thing, but ignoring them all together often makes it hard to diagnose issues.

Thanks Admin