Welcome to Tech Support Forum home to more then 136,000 problems solved. Issues have included: Spyware, Malware, Virus Issues, Windows, Microsoft, Linux, Networking, Security, Hardware, and Gaming Getting your problem solved is as easy as:
1. Registering for a free account
2. Asking your question
3. Receiving an answer

Registered members:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* See fewer ads.
* And much more..

 



Want to know how to post a question? click here Having problems with spyware and pop-ups? First Steps
Go Back   Tech Support Forum > Design Forum > Web Design & Programming
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read


Web Design & Programming Discussion of web design, and server-side & client-side scripting

Reply
 
LinkBack Thread Tools
Old 08-20-2007, 03:26 PM   #1 (permalink)
Registered User
 
Join Date: Aug 2007
Location: Denver Colorado
Posts: 7
OS: Windows XP


php and MySQL...having issues with connection

Hi All,
I am very new to computers and this is my first post. I am designing a website and want to be a little more interactive hence trying to learn php and for databases...MySQL. I do not have anything installed on my drive, however I am using Godaddy 's server ( I am on Linux).

My problem? I cannot get a connection. I am using this piece of code to initiate the connection:
<?php
//Sample Database Connection Syntax for PHP and MySQL.

//Connect To Database
$hostname="mysql.secureserver.net";
$username="your_dbusername";
$password="your_dbpassword";
$dbname="your_dbusername";
$usertable="your_tablename";
$yourfield = "your_field";
mysql_connect($hostname,$username, $password);
mysql_select_db($dbname);

# Check If Record Exists

$query = "SELECT * FROM $usertable";

$result = mysql_query($query);

if($result)
{
while($row = mysql_fetch_array($result))
{
$name = $row["$yourfield"] ;
echo "Name: ".$name."
";
}
}
?>

I get nothing. Of course I enter my password and username. I have been on the phone with tech support at Godaddy, however they do not offer support for the actual software operation.

I also tried a piece of code from a textbook( Larry Ullman's PHP for the World Wide Web):
<?php
ini_set ('display_errors',1);
error_reporting (E_ALL & ~E_NOTICE);
if ($dbc = mysql_connect ('mysql.secureserver.net', 'username', 'password'))
{print '<p>Successfully connected.</p>';
mysql_close();
}
esle{ print'<p>Could not connect.'</p>;
}
?>
No success with that either. The error message I keep getting is "unknown Host".

Has anybody had this issue. I tried downloading MySQL onto my drive but could not get it to activate ( I have an Apache2 server installed already). I am very anxious to start scripting and learning more. I thank you for your help in advance.
Dane
daneh is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Important Information
Join the #1 Tech Support Forum Today - It's Totally Free!

TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free.

Join TechSupportforum.com Today - Click Here

Old 08-20-2007, 04:08 PM   #2 (permalink)
Design Team Member
 
Redcore's Avatar
 
Join Date: Aug 2007
Location: Jamestown, CA
Posts: 713
OS: Linux Mint 7

My System

Re: php and MySQL...having issues with connection

First off, let me give you a very good PHP/MySQL tutorial site that I reference a lot:
http://www.php-mysql-tutorial.com/index.php

You should tell it to die and give you an error if it doesnt work...like this:

PHP Code:
mysql_connect("$hostname""$username""$password") or die(mysql_error());
mysql_select_db("$dbname") or die(mysql_error()); 
Let me know what errors it spits out. You shouldn't have to use that piece of code below if you just tell it to die and show you the error.
Redcore is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 08-20-2007, 04:25 PM   #3 (permalink)
Registered User
 
Join Date: Aug 2007
Location: Denver Colorado
Posts: 7
OS: Windows XP


Re: php and MySQL...having issues with connection

This is the error message I got:
Warning: mysql_connect(): Can't connect to local MySQL server through socket '/usr/local/mysql-5.0/data/mysql.sock' (2) in /home/content/d/n/s/dnscw/html/mysql.php on line 10
Can't connect to local MySQL server through socket '/usr/local/mysql-5.0/data/mysql.sock' (2)
I went to the tutorial and found that it is really only for people who have the software installed on their computer...I am using a remote server(Godaddy)
daneh is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 08-20-2007, 04:30 PM   #4 (permalink)
Design Team Member
 
Redcore's Avatar
 
Join Date: Aug 2007
Location: Jamestown, CA
Posts: 713
OS: Linux Mint 7

My System

Re: php and MySQL...having issues with connection

Who setup your database on GoDaddy? They should have something like phpMyAdmin (most web hosts do).
Redcore is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 08-20-2007, 04:43 PM   #5 (permalink)
Registered User
 
Join Date: Aug 2007
Location: Denver Colorado
Posts: 7
OS: Windows XP


Re: php and MySQL...having issues with connection

Yes they do have that. I set up a test database to work with. Is phpmy admin the same as php?

Also I tried unsuccessfully to download MySQL and the GUi software and could not get it to connect or initiate if you will. There was a lot of configuring and I may have done something wrong there. I did have an IT guy look at it and he couldn't get it to connect either.

Last edited by daneh; 08-20-2007 at 04:45 PM.
daneh is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 08-20-2007, 05:20 PM   #6 (permalink)
Design Team Member
 
Redcore's Avatar
 
Join Date: Aug 2007
Location: Jamestown, CA
Posts: 713
OS: Linux Mint 7

My System

Re: php and MySQL...having issues with connection

phpMyAdmin is just a PHP program that you can use to run MySQL databases...like a web-based MySQL GUI.

Does GoDaddy give you cPanel? My only guess is that you haven't created a username/password to access the database and are just using the username/password that is supposed to be for accessing phpMyAdmin.
Redcore is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 08-20-2007, 05:42 PM   #7 (permalink)
Registered User
 
Join Date: Aug 2007
Location: Denver Colorado
Posts: 7
OS: Windows XP


EEK! Re: php and MySQL...having issues with connection

I can't find anything about a cPanel, and I think you're right about logging in to myphpadmin and not to MySQL. Having said that, I see nowhere to create a password for MySQL. I thought the password I created in the beginnign was what I needed.

Godaddy is really no help whatsoever. I will give them a call and see what gives...AGAIN
daneh is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 08-20-2007, 05:47 PM   #8 (permalink)
Registered User
 
Join Date: Aug 2007
Location: Denver Colorado
Posts: 7
OS: Windows XP


Re: php and MySQL...having issues with connection

You know Redcore, I think the password is OK for MySQL...went back and checked the initail database creation and it calls for the username and passowrd to be created at the database level.

I realy want to have all this on my computer, however I cannot get the MySQL software from a download to work. Where did you get your from and do you use GUI tools? Thanks
daneh is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 08-20-2007, 06:08 PM   #9 (permalink)
Design Team Member
 
Redcore's Avatar
 
Join Date: Aug 2007
Location: Jamestown, CA
Posts: 713
OS: Linux Mint 7

My System

Re: php and MySQL...having issues with connection

I just use the MySQL and phpMyAdmin installed on the server I rent.

Perhaps you should just delete the database and start from scratch. If it still doesn't work, the host address is probably wrong. I can't really say because I don't have any of the details so I'm just giving blind suggestions.
Redcore is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 08-20-2007, 06:16 PM   #10 (permalink)
Registered User
 
Join Date: Aug 2007
Location: Denver Colorado
Posts: 7
OS: Windows XP


Re: php and MySQL...having issues with connection

I have done just that...deleted and created numerous new databases. I also called Godaddy and checked on the host name for running it on Linux instead of Windows...they have a piece of code for connecting to Linux. I have thought of using the IP address instead of the text given for the host name...any thoughts on that one? Thanks.
daneh is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 08-20-2007, 07:21 PM   #11 (permalink)
Design Team Member
 
Redcore's Avatar
 
Join Date: Aug 2007
Location: Jamestown, CA
Posts: 713
OS: Linux Mint 7

My System

Re: php and MySQL...having issues with connection

I would go with the IP address.
Redcore is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 08-21-2007, 09:34 AM   #12 (permalink)
Registered User
 
Join Date: Aug 2007
Location: Denver Colorado
Posts: 7
OS: Windows XP


Re: php and MySQL...having issues with connection

Thanks Redcore...hope this works!!
daneh is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 04-09-2009, 09:05 AM   #13 (permalink)
Registered User
 
Join Date: Apr 2009
Posts: 1
OS: XP


Re: php and MySQL...having issues with connection

No one has added a solution to this thread so here it is:

The answer is in the error message you are receiving: "unknown host"

If you are using Godaddy you will need to point your mysql_connect address to your Godaddy hosting account I.P address:

Code:
$dbh=mysql_connect ("10.6.166.223", "YOUR_USERNAME",
"YOUR_PASSWORD") or die('Cannot connect to the database because: ' . mysql_error());

mysql_select_db ("YOUR_DATABASE");
I had your exact problem and changing the host address to the I.P address resolves the issue.
paseywhitaker is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-05-2009, 12:51 PM   #14 (permalink)
Registered User
 
Join Date: May 2009
Posts: 1
OS: xp


Re: php and MySQL...having issues with connection

MR paseywhitaker...even i encountered the same problem at godaddy... wen i tried to make a php/mysql connection....by Godaddy hosting account I.P address ????...wat do u mean??..can u explain me clearly?
samvel2609 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -7. The time now is 05:21 PM.



Copyright 2001 - 2009, Tech Support Forum
Home Tips Plus | Outdoor Basecamp | Automotive Support Forum

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85