Jump to content

help)>>>adding a mysql server


redarrow

Recommended Posts

advance thank you i am currently changing my services with new servers,

i need to no is my setup correct for the my sql server to work with php thank you.

 

router 

 

ip 192.192.0.1  port 3307

 

sever ip 192.192.0.1

 

now to connect to that mysql server am i right to do this in php.

 


<?php

$db=mysql_connect("192.192.0.1:3307","username","password",);
mysql_select_db("what_ever",$db);

?>

 

let say username and password are set as username and password and the ip is 192.192.0.1

will this enable me to use the extenal mysql server cheers.

 

I think afther password is the port of the mysql connection not sure theo

Link to comment
Share on other sites

according to the .net i got it correct for mysql and php to talk to each other on sep servers.

 

if you see any problams tell me please cheers.

 

standard port for mysql is :3306

 

 

<?php

 

$db=mysql_connect("192.192.0.1:3306","username","password",);

mysql_select_db("what_ever",$db);

 

?>

router 

 

ip 192.192.0.1  port 3306

 

sever ip  nic card 192.192.0.1

 

is that correct for a internal setup to speek to php server and the mysql server

Link to comment
Share on other sites

This is on a internal network.

 

what errors? none yet waiting for server delevery sorry here by 1pm.

 

learning the process to setup a mysql server on a internal network, so php web server speaks to the mysql server.

 

i have setup the new web server to the new apache and php versions correctly they work fine.

 

now i need to no what the process to setup a internal mysql server.

 

example php5.ini mysql settings get the ip of the new mysql server correct?

 

 

Link to comment
Share on other sites

So you don't know if it's not working, cos its not up yet!

The php.ini file is irrelevant (maybe there is a way, I don't use it)

 

Try dropping the two firewalls (since its internal), if it works you'll have to set your iptables. Otherwise your syntax looks correct and your port is correct.

 

p.s. generally I install mysql first, also I presume you've followed the right install routes for building with mysql support. Nowadays I just use YUM to do the lot cos it updates so easily...

 

Here's some code from how I connect:

function db_test_mysql($db_host, $db_uname, $db_pass, $db_dbname)
{
//	CHECK CONNECTION
try
{
	if ( !@ ( $conn = mysql_connect($db_host, $db_uname, $db_pass) ) )
		throw new Exception (mysql_error());
}
catch (Exception $e)
{
	echo 'ERROR (MYSQL): ' . $e->getMessage();
	return array(-1, $conn, "?");
}
//	CHECK DATABASE	
try
{
	if ( !@ ( $res = mysql_select_db($db_dbname, $conn) ) )
		throw new Exception (mysql_error());
}
catch (Exception $e)
{
	echo 'ERROR (DB): ' . $e->getMessage();
	return array(-2, $conn, -2);
}	
return array(0, $conn, $res);
}

I generally don't let it echo anything but for this...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.