By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,987 Members | 971 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,987 IT Pros & Developers. It's quick & easy.

Connecting to remote MySQL server.

eragon
100+
P: 431
i tried using Awardspace.com fot the MySQL servers, and i keep getting errors from the server. So i tried 110mb.com for their servers, and still, i get errors! i put the information that they sent me into my scripts, and it wont work for me... so sad... for my username would i put sqltestsite_sqldb (sqltestsite is the name of my site, sqldb is my user) or would i just put sqldb? and for the host, would http://fdb1.awardspace.com/ work, or do i need to just put fdb1.awardspace.com, or is there a completely differend prefix i put?? PLease help!!!

Hoping you help,

Eragon
May 27 '07 #1
Share this Question
Share on Google+
29 Replies


Atli
Expert 5K+
P: 5,058
Hi.

I've edited the thread's title.

Please use good, descriptive, thread titles when you post new threads.
Refrain from using phrases like: 'Please help' or 'Need help' or just 'Help'.

Please read our Posting Guidelines before posting.

MODERATOR
May 27 '07 #2

Atli
Expert 5K+
P: 5,058
Could you show us the error's your getting, and perhaps some relevant code?

It's extremely hard to debug code you can't see.
May 27 '07 #3

eragon
100+
P: 431
sorry about that, im just getting a little frustrated... i cant get a good content management system working... i spent 2 hours following a tutorial, and when i was done, all i got was errors from my sql server. i need another sql server...
May 27 '07 #4

pbmods
Expert 5K+
P: 5,821
i tried using Awardspace.com fot the MySQL servers, and i keep getting errors from the server.
What errors are you getting? That ESP helmet I bought last year is still on backorder...

for my username would i put sqltestsite_sqldb
To connect to a MySQL server:
Expand|Select|Wrap|Line Numbers
  1. $handle = mysql_connect('hostname', 'username', 'password');
  2. mysql_select_db('database', $handle);
  3.  
http://fdb1.awardspace.com/ work, or do i need to just put fdb1.awardspace.com, or is there a completely differend prefix i put
You'd use fdb1.awardspace.com, since you're not using the http protocol.

For more information:
http://php.net/mysql_connect
May 27 '07 #5

eragon
100+
P: 431
Could you show us the error's your getting, and perhaps some relevant code?

It's extremely hard to debug code you can't see.
certainly, here is my PHP code, one of the many:

[PHP]<?php
// set your infomation.
$dbhost='http://fdb1.awardspace.com';
$dbusername='sqldb';
$dbuserpass='******';
$dbname='sqldb';

// connect to the mysql database server.
mysql_connect ($dbhost, $dbusername, $dbuserpass);
//select the database
mysql_select_db($dbname) or die('Cannot select database');

//create the table, customize it if you want
$query = "CREATE TABLE peep_online(
activity DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
member ENUM('y','n') NOT NULL DEFAULT 'n',
ip_address VARCHAR(255) NOT NULL,
refurl VARCHAR(255) NOT NULL,
user_agent VARCHAR(255) NOT NULL)";
$result = mysql_query($query);
echo "Table Created!";
?>[/PHP]

(stars subsituted for password)

and here is the error i get when i run the code:

Warning: mysql_connect(): Lost connection to MySQL server during query in /home/www/1221581815.awardspace.com/peep_onlinecreate.php on line 9

Warning: mysql_select_db(): Unknown MySQL Server Host 'db1.awardspace.com' (1) in /home/www/1221581815.awardspace.com/peep_onlinecreate.php on line 11

Warning: mysql_select_db(): A link to the server could not be established in /home/www/1221581815.awardspace.com/peep_onlinecreate.php on line 11
Cannot select database

i cant see what i am doing wrong... or can i ?
May 27 '07 #6

pbmods
Expert 5K+
P: 5,821
Warning: mysql_select_db(): Unknown MySQL Server Host 'db1.awardspace.com' (1) in /home/www/1221581815.awardspace.com/peep_onlinecreate.php on line 11
Is your MySQL server on the same machine / at the same address as your web server? In which case, you can use 'localhost' as the host name.
May 27 '07 #7

eragon
100+
P: 431
im just looking for a really easy way to edit the files on my website with a simple HTML form, and for those said files to remain that way untill i submit other data from the form mentioned above. I also need a way to append to the files for like, say a news bulletin that need to have articles added to it. i have the forms made, and they look great, now i need a PHP script that will take the data submitted by said forms and relay it back to the page of which the forms are meant to edit. All other systems i used (over 15) dont want to work. from the information i gathered, the information sent by the forms is stored in a MySQL database, and then retreived when a user loads the page and posted where it is supposed to go on said page. i have not the knowledge of PHP to complete these tasks alone, therefore i am turning to the forums to help me. (and Google is useless) can you help me?

If you want me to give more specific detail just ask.

Sincerely,

Eragon

P.S. WOOT! Im not a newbie no more! Im a member =p
May 27 '07 #8

eragon
100+
P: 431
ill try using localhost for the server name, and ill remove the http://
May 27 '07 #9

Atli
Expert 5K+
P: 5,058
btw you should add a die() call after your mysql_connect() function, so your code wont show you extra error messages. Only the first of you three error messages is needed, as the last two are a caused by the first one and serve only to cause confusion.
May 27 '07 #10

eragon
100+
P: 431
what if i remove the " or die('Cannot select database') " part?
May 27 '07 #11

eragon
100+
P: 431
that answers my question
May 27 '07 #12

eragon
100+
P: 431
lol, i wirte fast, i keep getting a "wait 30 secs" message
May 27 '07 #13

eragon
100+
P: 431
btw you should add a die() call after your mysql_connect() function, so your code wont show you extra error messages. Only the first of you three error messages is needed, as the last two are a caused by the first one and serve only to cause confusion.

How do i fix the first error??? ill add another die() thing, ill see if it works
May 27 '07 #14

eragon
100+
P: 431
changed code, looks like this:

[PHP]<?php
// set your infomation.
$dbhost='localhost';
$dbusername='1221581815_sqldb';
$dbuserpass='******';
$dbname='1221581815_sqldb';

// connect to the mysql database server.
$handle = mysql_connect('dbhost', 'dbusername', 'dbpassword');
mysql_select_db('dbname', $handle);

//create the table, customize it if you want
$query = "CREATE TABLE peep_online(
activity DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
member ENUM('y','n') NOT NULL DEFAULT 'n',
ip_address VARCHAR(255) NOT NULL,
refurl VARCHAR(255) NOT NULL,
user_agent VARCHAR(255) NOT NULL)";
$result = mysql_query($query);
echo "Table Created!";
?>[/PHP]

and i get this in return:


Warning: mysql_connect(): Lost connection to MySQL server during query in /home/www/1221581815.awardspace.com/peep_onlinecreate.php on line 9

Warning: mysql_select_db(): Unknown MySQL Server Host 'db1.awardspace.com' (1) in /home/www/1221581815.awardspace.com/peep_onlinecreate.php on line 11

Warning: mysql_select_db(): A link to the server could not be established in /home/www/1221581815.awardspace.com/peep_onlinecreate.php on line 11
Cannot select database


its like a plague!!! ill be back soon, im gonna take break, my computers trying to bite me...
May 27 '07 #15

Atli
Expert 5K+
P: 5,058
Its all about the server address. Your PHP code can't connect to the address you are giving it.
You need to find the correct address.

I cant see any problem in you PHP code, except from the incorrect server address.
May 27 '07 #16

eragon
100+
P: 431
im trying to fix it, the addresse Awardspace gave me is: fdb1.awardspace.com
does that make snse? (I put that in too, still an error, ill try again)
May 27 '07 #17

eragon
100+
P: 431
the error:

Warning: mysql_connect(): Lost connection to MySQL server during query in /home/www/1221581815.awardspace.com/peep_onlinecreate.php on line 9

Warning: mysql_select_db(): Unknown MySQL Server Host 'db1.awardspace.com' (1) in /home/www/1221581815.awardspace.com/peep_onlinecreate.php on line 11

Warning: mysql_select_db(): A link to the server could not be established in /home/www/1221581815.awardspace.com/peep_onlinecreate.php on line 11
Cannot select database

the code:

[PHP]<?php
// set your infomation.
$dbhost='fdb1.awardspace.com';
$dbusername='1221581815_sqldb';
$dbuserpass='******';
$dbname='1221581815_sqldb';

// connect to the mysql database server.
$handle = mysql_connect('dbhost', 'dbusername', 'dbpassword');
mysql_select_db('dbname', $handle);

//create the table, customize it if you want
$query = "CREATE TABLE peep_online(
activity DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
member ENUM('y','n') NOT NULL DEFAULT 'n',
ip_address VARCHAR(255) NOT NULL,
refurl VARCHAR(255) NOT NULL,
user_agent VARCHAR(255) NOT NULL)";
$result = mysql_query($query);
echo "Table Created!";
?>[/PHP]
May 27 '07 #18

pbmods
Expert 5K+
P: 5,821
Let's start with this line:

[PHP]<?php
$handle = mysql_connect('dbhost', 'dbusername', 'dbpassword');[/PHP]
Change it to this:

Expand|Select|Wrap|Line Numbers
  1. if(! ($handle = mysql_connect('dbhost', 'dbusername', 'dbpassword')))
  2.     throw new Exception('Unable to connect to the database.');
  3.  
There are four possibilities:
  1. Your hostname is incorrect.
  2. Your username is incorrect.
  3. Your password is incorrect.
  4. Any combination of the above three.

You might be supplying the correct hostname, but your username or password might be incorrect, or the Username you provided might not have access privileges.
May 27 '07 #19

eragon
100+
P: 431
you know, i never checked to see if im using the right password... lol

if that was my problem the whole time im gonna be [bleeped].
May 27 '07 #20

eragon
100+
P: 431
it kinda works!

The Code:
[PHP]<?php
// set your infomation.
$dbhost='fdb1.awardspace.com';
$dbusername='1221581815_sqldb';
$dbuserpass='******';
$dbname='1221581815_sqldb';

// connect to the mysql database server.
if(! ($handle = mysql_connect('dbhost', 'dbusername', 'dbpassword')))
throw new Exception('Unable to connect to the database.');

mysql_select_db('dbname', $handle);

//create the table, customize it if you want
$query = "CREATE TABLE peep_online(
activity DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
member ENUM('y','n') NOT NULL DEFAULT 'n',
ip_address VARCHAR(255) NOT NULL,
refurl VARCHAR(255) NOT NULL,
user_agent VARCHAR(255) NOT NULL)";
$result = mysql_query($query);
echo "Table Created!";
?>[/PHP]

The Error:
Parse error: parse error, unexpected T_NEW in /home/www/1221581815.awardspace.com/peep_onlinecreate.php on line 10

The Solution:
????????????????? ????? ?? ????? ? ? ??
May 27 '07 #21

pbmods
Expert 5K+
P: 5,821
The Error:
Parse error: parse error, unexpected T_NEW in /home/www/1221581815.awardspace.com/peep_onlinecreate.php on line 10

The Solution:
????????????????? ????? ?? ????? ? ? ??
Aw shoot. Did you mention you were using PHP 4? The statement I gave you won't work. You'll have to do this instead:

Expand|Select|Wrap|Line Numbers
  1. if(! ($handle = mysql_connect('dbhost', 'dbusername', 'dbpassword')))
  2.     die('Unable to connect to the database.');
  3.  
May 27 '07 #22

eragon
100+
P: 431
still have my problem
=[
May 27 '07 #23

eragon
100+
P: 431
MySQL dosn't like me, so ill move on. PHPCMS is very confusing, so i thought of an easier way Microsoft Access Database. i will make a form that writes to the database, and when a user views the page it retrieves from tha database.. pretty schnazzy, right? wrong. i know this will work, i just dont know how to make it work. can somebody send me a sample form code that will write to a database, and other codes to make it work? that would be great!

Sincerely,

Eragon
May 27 '07 #24

eragon
100+
P: 431
ok, i like dreamweaver now, all the functions i need are right there, so, now comes the big question:

ASP, JSP, ASP.net, or ColdFusion???

Which one is user-friendly, until i get a response, ill do ASP.
May 27 '07 #25

Atli
Expert 5K+
P: 5,058
ok, i like dreamweaver now, all the functions i need are right there, so, now comes the big question:

ASP, JSP, ASP.net, or ColdFusion???

Which one is user-friendly, until i get a response, ill do ASP.
Ok, your problem is not PHP, its your MySQL information. You simply need to find the correct information. You PHP code has no errors, it is only the server info that is incorrect.

If you want to try something else, however, I would reccomend ASP.NET.
Keep in mind tho, it's not as easy to learn as PHP.
May 28 '07 #26

eragon
100+
P: 431
asp.net you say? ok

i dont need to learn if Dreamweaver knows it for me. ;]
May 28 '07 #27

pbmods
Expert 5K+
P: 5,821
i dont need to learn if Dreamweaver knows it for me. ;]
You must post to WTF a lot.
May 28 '07 #28

eragon
100+
P: 431
thats funny... i still dont get it.
May 28 '07 #29

eragon
100+
P: 431
back to the origional topic... i decided to drop MySQL as a result of it not working for me, now im using a Microsoft Access Database, but Dreamweaver's built in functions wont work for me, so ill start from the top. i will make a sample db and asp.net page and i will post in the ASP.NET forum. look for the post, most likely titled "Linking *.mdb databases to ASP.NET page for editing." (That is, unless a mod changes the title [thats happened to all my posts]) offer help on the subject.

Sincerely,

Eragon

<?php ... ?> those question marks are how i feel about PHP.
May 28 '07 #30

Post your reply

Sign in to post your reply or Sign up for a free account.