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

Friday, February 18, 2022

[FIXED] Access a MySql Database from PHP (not on localhost)

 February 18, 2022     mysql, php, phpmyadmin     No comments   

Issue

there's this server: http://phpmyadmin.pvdata.fr/index.php , I can connect to it knowing the username and password and Server Choice.

Once I connect to it, it shows under MySql the following information: (I'm Translating from French)

Server:  sql6 (sql6 via TCP/IP)
Server Version: 5.0.92-87
Protocol Version: 10
Username: pvdata@10.5.1.3
Character for MySql: UTF-8 Unicode (utf8)

So I tried using the following code in order to connect to the Database:

<?php
// Create connection
$username = "pvdata";
$password = "xxxxxxxx";
$hostname = "10.5.1.3"; 
$dbhandle = mysql_connect($hostname, $username, $password) 
or die("Unable to connect to MySQL");
?>

But it didn't work, it's saying: "A connection attempt failed because the connected party did not properly respond after a period of time". What am I doing wrong?


Solution

Go to your phpMyAdmin installation and look for the file config.inc.php. Open that file, and check which hostname / ip is being used for SQL6. That is the IP you should use for your mysql_connect()



Answered By - nl-x
  • 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