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

Monday, January 31, 2022

[FIXED] Remotely connect to MySQL using PHP script

 January 31, 2022     css, mysql, php, phpmyadmin, xampp     No comments   

Issue

My MySQL server is running on one PC(xampp).I want to insert data into the MySQL database(remote PC) using PHP script from another PC(client).I have made a website using HTML5 and CSS(client).As PHP runs on server,how do I connect to remote PC using a simple webpage?


Solution

You can connect to a mysql database from anywhere using php. Just change the location to point to the remote server.

$servername = "ip_of_remote_server";
$username = "username";
$password = "password";

// Create connection
$conn = new mysqli($servername, $username, $password);

But you have to configure the mysql server to allow remote connections if you are using the root user. See: How to allow remote connection to mysql



Answered By - DustinPianalto
  • 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