PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, January 20, 2022

[FIXED] PHP Cannot connect to database config

 January 20, 2022     config, database, mysql, php, phpmyadmin     No comments   

Issue

I have a folder structure like this:

|Home

|____|Admin

|__________|Pages

|

|

|db_config.php

Files located in the home directory, I set the connection to the db_config.php file as follows: include("db_config.php");

For files located in the pages directory, I set to:

include("..\\..\\db_config.php");

This setting works fine on my local and doesn't work when I up my website to 000webhost. What can I do to solve this problem? Thanks


Solution

Simply change

include("..\..\db_config.php");

to

include("../../db_config.php");

\ only works on windows, Linux uses / (which your host is using probably) BTW, always use /, windows accepts it too.



Answered By - Spoody
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing