# Undefined variable $conn

**URL:** <https://www.phphelp.com/t/undefined-variable-conn/34473>\
**Category:** MySQL database\
**Created:** [February 4, 2022, 10:18pm UTC](https://www.phphelp.com/t/undefined-variable-conn/34473 "2022-02-04T22:18:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![samoraj](https://www.phphelp.com/letter_avatar_proxy/v4/letter/s/73ab20/32.png) [@samoraj](https://www.phphelp.com/u/samoraj)\
**Post date:** [February 4, 2022, 10:18pm UTC](https://www.phphelp.com/t/undefined-variable-conn/34473/1 "2022-02-04T22:18:13Z")

</div>

Hello, in web host have config.php from my database. On my computer have local server. When from php file on my computer i try to connect with databasse on web host with connfig file on web host somting wrong…

config.php on web host

```auto
<?php
	
	$servername = 'host';
	$username = 'user';
	$password = 'pass';
	$dbname = 'db';

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname); 
set_time_limit(500);
// Check connection
if ($conn->connect_error) {
  die("Проблем с интернета или достъпа ! ");
}
?>
```

* * *

Playlist.php local

```auto
include 'https://website.eu/config.php';
 
$sql ="SELECT * FROM playlist WHERE playnow > 0 ORDER BY playnow ASC" ;
$result = $conn->query($sql);
```

* * *

Error:  
**Warning** : Undefined variable $conn in **C:\Users\user\Desktop\laragon-portable\www\loadplaylist.php** on line **7**

**Fatal error** : Uncaught Error: Call to a member function query() on null in C:\Users\user\Desktop\laragon-portable\www\loadplaylist.php:7 Stack trace: #0 {main} thrown in **C:\Users\user\Desktop\laragon-portable\www\loadplaylist.php** on line **7**

* * *

How to fix it ?

---

<div class="post-metadata">

**Author:** ![phdr](https://www.phphelp.com/letter_avatar_proxy/v4/letter/p/91b2a8/32.png) [@phdr](https://www.phphelp.com/u/phdr)\
**Post date:** [February 5, 2022, 1:37pm UTC](https://www.phphelp.com/t/undefined-variable-conn/34473/2 "2022-02-05T13:37:25Z")

</div>

Any php variable in the server-side code being executed on the web host only exists on the web host. Making a http(s) request to the web host will only receive any output from that code, the same as if you browse to that url on the web host.

Since what you are showing us cannot work, what is the overall top level goal you are trying to accomplish?

---

<div class="post-metadata">

**Author:** ![samoraj](https://www.phphelp.com/letter_avatar_proxy/v4/letter/s/73ab20/32.png) [@samoraj](https://www.phphelp.com/u/samoraj)\
**Post date:** [February 5, 2022, 5:45pm UTC](https://www.phphelp.com/t/undefined-variable-conn/34473/3 "2022-02-05T17:45:18Z")

</div>

This is a client project and I don’t want it to see my settings. Is there a way to hide them?

---

<div class="post-metadata">

**Author:** ![astonecipher](https://www.phphelp.com/user_avatar/www.phphelp.com/astonecipher/32/2797_2.png) [@astonecipher](https://www.phphelp.com/u/astonecipher)\
**Post date:** [February 8, 2022, 10:51pm UTC](https://www.phphelp.com/t/undefined-variable-conn/34473/4 "2022-02-08T22:51:16Z")

</div>

Centralized configuration manager, but it adds complexity
