kevinkhan Posted November 27, 2009 Share Posted November 27, 2009 I have this script below <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=windows-1250"> <meta name="generator" content="PSPad editor, www.pspad.com"> <title></title> </head> <body> <?php $hostname = "hostname"; $database = "database"; $user = "user"; $pass = "pass"; $dbcn = mysql_connect($hostname, $user, $pass); if(!$dbcn) { exit ("<p>Error connecting to the site database.</p>"); } $dbsel = mysql_select_db($database, $dbcn); if(!$dbsel) { exit ("<p>Error opening the site database.</p>"); } $result = mysql_query("SELECT * From password",$dbcn); if(!$result) { die("Database query failed: ".mysql_error()); } while($row = mysql_fetch_array($result)) { echo $row["mypass"]."<br />"; } mysql_close($dbcn); ?> </body> </html> When i upload the code to a server it works grand but is there away i can view whats in the database if i run the script on my own local apache server.. Im getting this error Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'server name' (10060) in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\testing\testing.php on line 17 Error connecting to the site database. Thanks for any help ye can provide.. Quote Link to comment https://forums.phpfreaks.com/topic/183108-is-there-a-way-of-connecting-to-a-database-on-a-server-from-a-local-computer/ Share on other sites More sharing options...
cags Posted November 27, 2009 Share Posted November 27, 2009 That would depend on the value of $hostname and the settings on your server. A lot servers are setup to only allow access from localhost. Quote Link to comment https://forums.phpfreaks.com/topic/183108-is-there-a-way-of-connecting-to-a-database-on-a-server-from-a-local-computer/#findComment-966377 Share on other sites More sharing options...
Zane Posted November 27, 2009 Share Posted November 27, 2009 You would need to authenticate your WAN IP on the MySQL server your trying to connect to. In other words, you would need to add ANOTHER USER to this "server name" that has the credentials of your local computer. (i.e. your WAN IP) Quote Link to comment https://forums.phpfreaks.com/topic/183108-is-there-a-way-of-connecting-to-a-database-on-a-server-from-a-local-computer/#findComment-966379 Share on other sites More sharing options...
JAY6390 Posted November 27, 2009 Share Posted November 27, 2009 Yeah. If your server is on a CPANEL account you can do this very simply Go into the Remote MySQL in the Database panel and then add the wildcard % to the allowed hosts. Once you have, it should work fine Quote Link to comment https://forums.phpfreaks.com/topic/183108-is-there-a-way-of-connecting-to-a-database-on-a-server-from-a-local-computer/#findComment-966390 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.