Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8410143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:06:02+00:00 2026-06-10T00:06:02+00:00

I’ve just finished writing a website which is working very well on my local

  • 0

I’ve just finished writing a website which is working very well on my local server (xampp).
The following is my connection database definitions for the local server:

<?php
  $host="localhost";
  $username="root";
  $password="1234";
  $db_name="partnership";

  mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
  mysql_select_db("$db_name")or die("cannot select DB");
?>

I’ve loaded my files successfully and put them on the remote server (www.mydomain.com) and I’ve created the relevant database ‘partnership’ (successfully imported all Tables from phpMySQL local server to the remote server).

I can view the website (www.mydomain.com) but with no connection to the database (MySQL).
The error message is of course “cannot connect”.

I’ve changed $host="localhost" to $host=”www.mydomain.com” but still getting the same error message.

Any assistance on the above issue would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:06:03+00:00Added an answer on June 10, 2026 at 12:06 am

    If you are using cPanel, when you create the MySQL table, make sure you assign your user to it (trivial, I know, but Ive forgotten about it a few times myself.)

    If your script is running from your remote server, just stick with localhost. Will work fine.

    Last, my only suggestion until a better answer is said, try using

    $host = 'localhost';
    $user = 'username'; // Im pretty sure your username isn't root.
    $pass = '1234';
    $db = 'partnership'; 
    /* Alot of hosts like to append your cPanel login to your db and username fields.
    Check to see what your table is. It might actually be 'youruser_partnership'  */
    
    $mysqli = new mysqli($host, $user , $pass, $db);
    if (mysqli_connect_error()) {
        die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
    }
    

    If your host supports mysqli (most do). If not, when you do your die statement, still use die(mysql_error()); to get the exact error. It will more than likely be your username/password you created and assigned to your database

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just finished writing my very first command-line tool in Objective-C, compiled it, and
I have just finished writing the core section of a project I am working
I'm just about finished writing a backend for a website in PHP/MySQL/jQuery, but my
I just finished writing most of a large intranet website for a company, but
i have a question about sockets/clients.... I just finished writing a client server program
In a project I am working on, I just finished writing an XSD for
I just finished writing a large program that uses a pretty large database file.
I've just finished writing a pretty substantial amount of Javascript (I'll spare you everything
I'm writing a little DirectX model viewer. I just finished writing my scene manger.
Just finished up my first mvc4 app. Everything is working great until I deploy

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.