Computer problems,Computer help
*AX SOFT>>>Programming & Design

How do I access my database?


I've been designing a file server for a customer. I've been using PHP for the upload forms and a MySQL database to save file information.
Everything is perfect when I run it on my personal test domain but when I installed it on the customers domain, the scripts were unable to access the host. This is the error:

Unknown MySQL server host 'db1408.perfora.net' (1)

where db1408.perfora.net is the hostname. I concluded that I can only access the host from my domain because the database is somehow linked to my domain. I set it up through 1and1.com and it uses phpMyAdmin.

To connect I issue the following:
$connection = @mysql_connect($hostname, $user, $pass)
or die(mysql_error());
$dbs = @mysql_select_db($database, $connection) or
die(mysql_error());

where the variables are available in a config file.

How should I connect to a database if I'm connecting to a host that's not on my domain?

Thanks for the answer " rhonz a. " , but that's not it. I also used this on other pages:
mysql_connect("$hostname", "$user", "$pass")or die("cannot connect");
mysql_select_db("$database")or die("cannot select DB");

So the '@' sign shouldn't make a difference.

It depends on the configuration of the MySQL server, which by default is indeed locked to your domain. SOME web hosts allow you to specify additional IP addresses for access, and if you have that capability, either through a secure shell (SSH) or a cPanel interface, you'll need to add your customer's IP address to those permitted access to the MySQL server.

Additionally, note that when you log in as a user via PHP, the default assumption is usually that the connection is from localhost (127.0.0.1), so "fred" to the server would really look like "fred@localhost", which is NOT the same as "fred@192.168.0.3" or any other IP address or domain. It MIGHT be possible to use patterns to match any domain, or a range of IP addressees, though that's quite a bit less secure, and may not be allowed on your server, again depending on how it's configured.

try to remove the "@" sign and remove the $connection parameter from mysql_select_db

$connection = mysql_connect($hostname, $user, $pass)
or die(mysql_error());
$dbs = mysql_select_db($database) or
die(mysql_error());

Tags
  General - Computers & Internet   Software   Security   Programming & Design   Facebook   Flickr   Google   MSN   MySpace
Related information
  • Help To find this book ?

    Check the source.

    ...
  • When we should (in what situation/scenario) we are supposed to use inline function in spite of normal function

    I use Visual Basic, which has no such thing. However, if I remember correctly, the Inline keyword forces the code of the method being called to be compiled in-line (hence the name). So, inste...

  • <header.h> / "header.h" mein difference and normal function /inline function mein difference?

    <header.h> :means it execute or it include the only that file which are belonging or present in a TC folder header.h :means it execute all the header files which r present in u r hard dis...

  • EdgeCam Help?

    May be you can contact a edgecam expert live at website like ...

  • Array of Structures?

    Yes. Contrary to what the previous responder said, structure assignment, as shown in your example, is valid in ANSI C.

    ...
  • Music for my website?

    I love notepad. Good job! If you want people to be able to download them, then all you need is a link. Use anchor tags, and upload your files as you please. If you are asking what you need ...

  • Free Clothes On Zwinky?

    to unlock every thing you have to press f2

    ...
  • Html big doubt?

    Your syntax is incorrect and it's recognizing your HTML as just plain text. Make sure you have all of your tags closed (<HTML>,<HEAD>,<BODY>,etc) and everything is symmetric....

  •  

    Categories--Copyright/IP Policy--Contact Webmaster