PDA

View Full Version : PHP script installation help


Barbara
10-20-03, 08:06 PM
I'm trying to install a PHP script at 1&1 that I've previously installed without any problems on another server. I'm getting the following error when I try to submit the mySQL configuration information from the install program:


Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2): 2002


I submitted a request to support and this is the information that I received:


The problem is probably not too complex. You need to set the socket at
3306. This is the port that allows you to connect to the mySQL
database. Please give this a try.


I'm totally unsure on how to do this. I've responded to the email, but I'm hoping to get a quicker response. Is this something I set up in the script?

Chicken
10-20-03, 08:35 PM
I found some info on the web regarding setting the socket but to be honest, it's beyond me. If you search google for...

MySQL "setting the socket"

-you can find the same info, but I wouldn't know how to apply it without really looking more into it and/or asking someone who has a better grasp. Maybe the information there will help you...

Barbara
10-20-03, 08:47 PM
Thanks. Googling was on my to do list for tomorrow (when I'm on a faster connection).

salad
10-20-03, 10:09 PM
If your normal mysql connection is like

$handle = mysql_pconnect("localhost",$user,$password);

you now do:
$handle = mysql_pconnect("127.0.0.1:3306", $user,$pass);

See the notes at:
http://www.php.net/manual/en/function.mysql-connect.php
for specifics

Chicken
10-21-03, 01:29 AM
That would make sense salad .... yum.. now I'm hungry. Going to go order pizza.

S3G
10-21-03, 01:55 AM
Or if your script has a configuration file, check that there isn't a port setting. If there is it obviously needs to be set to 3306.

If your still stuck tell us what script and probably someone will know the answer :)

Robert
10-21-03, 04:48 AM
At first, it looked like your mysql was down (maybe they should reboot).

Secondly, you should be able to use "localhost" and not the port itself. If that's what they want, just do as salad said localhost:3306

Barbara
10-21-03, 06:04 AM
Thanks for all the help so far. The script that I'm trying to install is cS 5 (http://www.ioger.co.uk/scripts/story/). To test it, I installed it here (http://cultforum.com/story/index.php) and it's working OK. It's when I try to install it at 1&1 that I have the problems.

The config.php file looks like this:


<?
################################################## #######
# cS 5 (v5.0.0) (C) 2002 Ian Johnson #
# See Readme.txt for new features #
# Mod date: 21/08/2002 #
################################################## #######
# For explainations on these varibales please see #
# Readme.txt before posting help messages in the forums #
################################################## #######

# Configure the MySQl server settings
# $config['dbserver'] sets the server name
# $config['dbuser'] sets the username
# $config['dbpass'] sets the password
# $config['dbname'] sets the database name
$config['dbserver'] = "localhost";
$config['dbuser'] = "";
$config['dbpass'] = "";
$config['dbname'] = "story";

# Path setting - THIS IS IMPORTANT! if its wrong, nothing will work
$config[path] = "";

# Configure the table names
#Sets the name for the table to store the story parts in
$config[table] = "cs_story";

#Sets the name of the table to store the titles to stories in
$config[ttable] = "cs_titles";

# Sets the name of the table to store the filter words in
$config[badwordtable] = "cs_filter";

# Sets the name of the table to store recommend data in
$config[rtable] = "cs_recommend";

# Table to store the admin users in
$config[admin] = "cs_admin";

# Core Confige Values
# Tags to allow to pass through the HTML filter
$config[allowedtags] = "<b>, <br>, <i>, <center>";
# Filter all posts for bad words? (0 is no, 1 is yes)
$config[badwords] = "1";
# Allow visitors to recommend the story? (0 is no, 1 is yes)
$config[recommend] = "1";
# URL to your story directory, WITHOUT trailing slash
$config[url] = "http://";

# Email settings
# sets whether to notify the admin each time a new part is added
# ian@ioger.co.uk is the address to send the emails to
$config[mail] = "0";
$config[adminmail] = "";

# General apparence settings
$config[tablecolor] = "#E9E9E9";
$config[font] = "Arial";

# Don't change whats below, it won't do anything only confuse you when you have a different version than what available
$config[version] = "5.0";
$config[fullversion] = "5.0 (r 1-20-000 e 1-2)";
?>


At 1&1,


The MySQL database is stored on a separate database server behind a firewall to protect your data. You can only access this database server and your database exclusively through your site. Direct access to the MySQL database using a home PC (external ODBC connection) cannot be established.


so localhost is not the host name. They say to use db06.perfora.net, so I tried to use db06.perfora.net:3306, but I got the same error.

I also found this in the dbdriver.php file:


function connect() {

global $config;

if ($this->dbh == 0) {
$this->dbh = mysql_connect($config['dbserver'],$config['dbuser'],$config['dbpass']);
}
if (!$this->dbh) {
$this->not_right("Unable to connect to the database!");
}
mysql_select_db($config['dbname'],$this->dbh);

}

Robert
10-21-03, 06:33 AM
use db06.perfora.net and not db06.perfora.net:3306

and see what that yields.

Barbara
10-21-03, 06:36 AM
That's what I tried first.

xerocity.com
10-21-03, 07:26 AM
There are only 3 things that I can think of. One is try to get the IP address of the mysql server and try that. The second is that their firewall isn't configured right. The third isn't really a solution but it may help you.

Copy the following code and upload it (change the username, password and database names).


<?php

// Connect to MySQL Database
$db = mysql_connect("IP ADDRESS", "USERNAME", "PASSWORD");
mysql_select_db("DATABASE",$db);

?>


Give that a try. If it doesn't kick back any errors then it connected correctly and there is something wrong somewhere in the code of cS 5 (unlikely since you have gotten a working version of it).

Personally I would ask them if they have MySQL using a non-standard port. The correct and standard port id 3306 and php will automagically use this port when connecting if you do not enter a port number.

Scratch that last idea, I just saw that they said that the port is 3306

noncompare
10-21-03, 08:14 AM
This is one of those situations where a bazillion factors can be at play.

I haven't coded with PHP and MySQL for a long time now, so this may not be of much help. But basically the support person is telling you to specify the port number to go with the host name (host_name:port_num), or in this case you should have that correct (db06.perfora.net:3306), though depending on the config of their server, note that the hostname parameter can be specified with an optional PATHname to specify the domain socket path, from which the socket should be specified as a full pathname (not just the port number).

Since there doesn't seem to be anythign out of the ordinary in the script code you displayed, and that it worked fine on your other site, then presuming you've examined and reexamined the config details you entered into the script and verified that your database account has been set-up and is working in the first place... then another email to support might prove quicker as to the exact specs needed to connect to their mysql servers?

Note too what you enter in the config file. As with Perl and similar scripts, these things have a nasty tendency to go haywire even with a single mistyped character. If you've done so and are sure the prob isn't in your input, then short of examining your script itself, are you able to verify that the database itself is up and running (and accepting connections)
from db06.perfora.net?

Point is simply that with so many factors that can cause the problem, sometimes it's the simplest things that are overlooked, like ya know, maybe someone accidentally kicked the power cable for the db06 machine in the perfora machine? :D

Also, sometimes the error messages can be a bit misleading. While it could just as well be a "sockets" problem, the fact is that this might just be a symptom, and the main problem is still that "you can't connect to the database" (sockets or otherwise).

Barbara
10-21-03, 08:33 PM
Originally posted by xerocity.com:

There are only 3 things that I can think of. One is try to get the IP address of the mysql server and try that. The second is that their firewall isn't configured right. The third isn't really a solution but it may help you.

Copy the following code and upload it (change the username, password and database names).


<?php

// Connect to MySQL Database
$db = mysql_connect("IP ADDRESS", "USERNAME", "PASSWORD");
mysql_select_db("DATABASE",$db);

?>


Give that a try. If it doesn't kick back any errors then it connected correctly and there is something wrong somewhere in the code of cS 5 (unlikely since you have gotten a working version of it).

Personally I would ask them if they have MySQL using a non-standard port. The correct and standard port id 3306 and php will automagically use this port when connecting if you do not enter a port number.

Scratch that last idea, I just saw that they said that the port is 3306

Thanks for everyone's help, but I'm still confuzzled. I tried the above script both without (http://fracturedtales.com/test.php) and with (http://fracturedtales.com/test2.php) the port. I'm assuming that since I don't see an error message that it worked correctly. That leaves me thinking that it's the code in the script, but that confuzzles me even more since the same code is working on a different server. Maybe I should just host it there.

Chicken
10-22-03, 06:32 AM
Originally posted by Barbara:

Maybe I should just host it there.
For an end result of negative -10 in terms of mental anguish and insanity, I'd concur.

Barbara
10-22-03, 09:38 AM
Originally posted by Chicken:

For an end result of negative -10 in terms of mental anguish and insanity, I'd concur.

True enough. I get enough of this :banghead: at my RL job and dealing with my teenager, lol.

xerocity.com
10-23-03, 01:49 PM
For some odd reason this post and possibly a reason why there was an error came back into my mind. Does 1&1 have safe mode enabled? That could cause errors like this depending on how it calls the variables.

Just a thought.

Barbara
10-24-03, 06:39 AM
How would I be able to tell (especially since my emails to support have apparently been sucked into a black hole)?

xerocity.com
10-24-03, 07:09 AM
Originally posted by Barbara:

How would I be able to tell (especially since my emails to support have apparently been sucked into a black hole)?

Create anew php file and put only this into it:


<?php
phpinfo();
?>


Then upload it and bring up the page. In the Configuration >> PHP Core section you will find "safe_mode" (it'll be about two-thrids down in the table). Look to the rows on the right they will tell you if safe mode is enabled. For example, if it says "Off" and "Off", it means that your website doesn't have it configured and the server doesn't have it configure either.