![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| 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: * 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 |
|
|||||||
| Web Design & Programming Discussion of web design, and server-side & client-side scripting |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#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 |
|
|
|
| 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 |
|
|
#2 (permalink) |
|
Design Team Member
|
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:
|
|
|
|
|
|
#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) |
|
|
|
|
|
#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. |
|
|
|
|
|
#6 (permalink) |
|
Design Team Member
|
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. |
|
|
|
|
|
#7 (permalink) |
|
Registered User
Join Date: Aug 2007
Location: Denver Colorado
Posts: 7
OS: Windows XP
|
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 |
|
|
|
|
|
#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 |
|
|
|
|
|
#9 (permalink) |
|
Design Team Member
|
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. |
|
|
|
|
|
#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.
|
|
|
|
|
|
#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");
|
|
|
|
|
|
#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?
|
|
|
|
![]() |
| Thread Tools | |
|
|