I’ve created a database into my server (not localhost) and when i’m trying to put a few data inside my database using a php file, it shows two warnings: ‘A link to the server could not be established’ and ‘Can’t connect to MySQL server on ‘localhost’ (10061)’ .
I did many things to make it right, but nothing worked =(
Here’s a little bit of code:
<?php
define('DB_USER',"X");
define('DB_PASSWORD',"X");
define('DB_DATABASE',"X");
define('DB_SERVER',"www.X.com.br");
?>
$con = mysql_connect(DB_SERVER,DB_USER, DB_PASSWORD) or die(mysql_error());
$db = mysql_select_db(DB_DATABASE) or die(mysql_error());
require_once __DIR__. '/db_connect.php';
$db = new DB_CONNECT();
$query = "SELECT *FROM carteira";
$result = mysql_query($query) or die(mysql_error());
Could someone help me?
It sounds like you are not connecting to your database properly. First make sure you are actually connected to your database before you try and edit things in your tables.
This code will try and connect and if it doesn’t it will let you know you did not connect.
If you know your connection details are correct and you still cannot connect it may because there is a remote access permission error. Assuming your connecting to a new remote database and your work is not also hosted with that partner; Which means your host server does not like remote requests which means you need to go to your user panel and add your IP address to the exceptions access list to grant you access to your database remotely.