help installing a php script

Status
Not open for further replies.

pietimer

New Member
Messages
31
Reaction score
0
Points
0
I'm trying to install this php script and I'm getting hung up.

I've gotten to the fifth part in the instructions where it says

5. Configure db.php

Change to the phpgiftreg/ directory and edit the db.php file. There's a line
with a call to mysql_connect(). Change it to suit your setup.

mysql_connect("host","username","password")
or die("Could not connect: " . mysql_error());

I edited my db.php file to say

mysql_connect("pietimer.exofire.net","admin","admin")
or die("Could not connect: " . mysql_error());

but I get this error when I try to access pietimer.exofire.net/giftreg/index.php

Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server at 'reading initial communication packet', system error: 111 in /home/pietimer/public_html/giftreg/db.php on line 16
Could not connect: Lost connection to MySQL server at 'reading initial communication packet', system error: 111

Anyone know what's going on?

Thanks!
 

DeadBattery

Community Support Team
Community Support
Messages
4,018
Reaction score
120
Points
0
You need to use localhost and use your cPanel username and password.
mysql_connect("localhost","pietimer","password")
or die("Could not connect: " . mysql_error());
Make sure your database is like pietimer_databasename also. :)
 

pietimer

New Member
Messages
31
Reaction score
0
Points
0
Hey! Thanks! That was exactly what I needed.

Now I have another problem, want to solve it for me?

When I try to enter a username/password it says:

Could not query: No database selected

I named my database: pietimer_phpgiftreg like you said. Could it have something to do with the last instruction?

7. Create Apache alias

Edit your httpd.conf and add an Alias like so:

Alias /phpgiftreg/ "/path/to/phpgiftreg/"

The trailing slashes are important. Restart the web server and you should
be good to go.

I don't really know whats going on...

Thanks! You're my best friend.
 

sunils

New Member
Messages
2,266
Reaction score
0
Points
0
Did you go to phpmysql option in you CPanel and then created the database with the correct name?

Did you creat a mysql user and gave him the previlages ?

You have to do that before attempting to open the database via your php code and query for some data.
 

pietimer

New Member
Messages
31
Reaction score
0
Points
0
Thanks for the suggestion but it's a yes on both accounts. I created the database in phpmysql with the name pietimer_giftreg and I created a mysql user with all privileges, attached it to that database, and used that username/password in my db.php file.

Any ideas?

Thanks.
 

xPlozion

New Member
Messages
868
Reaction score
1
Points
0
step 7 should not play any part in the mysql error. Step 7 only changes www.blah.com/path/to/phpgiftreg to www.blah.com/phpgiftreg (basically creating an symbolic link (those who are familiar with *nix based systems know what this is) to the directory /path/to/phpgiftreg.

onto your mysql problem. you do not put in your cpanel username/password to gain access to the mysql db. You have to create a username/password and a database from the mysql setup in cpanel and add the user you created to the database you want to use. then in the db.php file, look for mysql_connect (which you already have, and put the newly created username/password with the host being localhost and then look for mysql_select_db, and put the newly created database in there.

PHP:
mysql_connect("localhost", "user", "pass");

mysql_select_db("database");

Remember, your username and database are prefixed with your cpanel username. Example: pietimer_username, pietimer_database; that's if your cpanel username is pietimer ;)

-xP
 
Last edited:

pietimer

New Member
Messages
31
Reaction score
0
Points
0
Whoops, didn't change the database name! Thanks for the pointers and help everybody!
 

Nathan H

New Member
Messages
562
Reaction score
0
Points
0
*thread closed*
If you need any more help with this issue feel free to re-open this thread or create another one
 
Status
Not open for further replies.
Top