Reply
Learning PHP/MySQL
Old 10-07-2002, 11:45 PM Learning PHP/MySQL
Novice Talker

Posts: 8
i read a tutorial on php/mysql here:

http://www.freewebmasterhelp.com/tutorials/phpmysql/2

i made a php file with the code it says you need to make the database but when i try to load it in my browser i get this:
-------------------------
Warning: Can't connect to MySQL server on 'localhost' (10061) in c:\dn\nuclub\datatest.php on line 5

Warning: MySQL Connection Failed: Can't connect to MySQL server on 'localhost' (10061) in c:\dn\nuclub\datatest.php on line 5
Unable to select database
-------------------------

any ideas?
whitchman is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 10-10-2002, 09:14 AM
Experienced Talker

Posts: 33
Looks like your connect sequence to MySQL has problems. Post a code snippet so we can see what the trouble is.
__________________
Linkstream Technologies, LLC
Hosting Excellence Since 1999
http://www.linkstream.net
Shared / Reseller / Dedicated Servers
Featuring cPanel and DirectAdmin
alchiba is offline
Reply With Quote
View Public Profile Visit alchiba's homepage!
 
Old 10-10-2002, 03:43 PM
david's Avatar
King Spam Talker

Posts: 1,314
Location: Glasgow, UK
Assuming it is this code:
PHP Code:
<?
$user
="username";
$password="password";
$database="database";
mysql_connect(localhost,$user,$password);
@
mysql_select_db($database) or die( "Unable to select database");
$query="CREATE TABLE contacts (id int(6) NOT NULL auto_increment,first varchar(15) NOT NULL,last varchar(15) NOT NULL,phone varchar(20) NOT NULL,mobile varchar(20) NOT NULL,fax varchar(20) NOT NULL,email varchar(30) NOT NULL,web varchar(30) NOT NULL,PRIMARY KEY (id),UNIQUE id (id),KEY id_2 (id))";
mysql_query($query);
mysql_close();
?>
I would say that from your error it looks like either your database is not on localhost or its not operating correctly (unless I made a typo in that code )

Have you looked at the section 'Connecting To The Database' on http://www.freewebmasterhelp.com/tutorials/phpmysql/3
That may help a bit.
__________________
Free Webmaster Help - Everything a webmaster needs - for free
Free-Webhosting.info - Free web hosts reviewed and rated
Web Hosting Hunt - Impartial hosting directory - Add your host today for FREE
david is offline
Reply With Quote
View Public Profile Visit david's homepage!
 
Old 10-10-2002, 07:02 PM
Novice Talker

Posts: 8
My problem is that there is no database to connect to. I have to make one. How can i make one through php?
whitchman is offline
Reply With Quote
View Public Profile
 
Old 10-10-2002, 11:55 PM
AhmedF's Avatar
Left for Better Places

Posts: 258
The problem is that you cannot seem to be able to connect to the 'MySQL' server.

Do you have something internal like a firewall that could be blocking access?

Also, try putting localhost in quotations ... "localhost"
AhmedF is offline
Reply With Quote
View Public Profile
 
Old 10-11-2002, 03:44 PM
david's Avatar
King Spam Talker

Posts: 1,314
Location: Glasgow, UK
Have you got MySQL installed? What platform are you running it on? If I remember rightly, MySQL for Windows comes with an administration tool which allows you to create databases

One of the best php scripts you can get to administer databases is PHPMyAdmin (http://www.phpwizard.net/projects/phpMyAdmin/). Just download it, unzip it, and then log into the database with the username root and leave the password blank. You can then set up databases from there.
__________________
Free Webmaster Help - Everything a webmaster needs - for free
Free-Webhosting.info - Free web hosts reviewed and rated
Web Hosting Hunt - Impartial hosting directory - Add your host today for FREE
david is offline
Reply With Quote
View Public Profile Visit david's homepage!
 
Old 10-11-2002, 04:22 PM
Novice Talker

Posts: 8
I figured it out. I just used winmysqladmin to create the database. thanks guys.
whitchman is offline
Reply With Quote
View Public Profile
 
Old 10-12-2002, 07:27 AM
conkermaniac's Avatar
The Nutty Moderator

Posts: 1,012
Location: China
Quote:
Originally posted by david
If I remember rightly, MySQL for Windows comes with an administration tool which allows you to create databases
Yes, that would be WinMySQLAdmin...When I'm practicing creating scripts and databases, I just leave winmysqladmin on in the background, and use an easy-to-use script to create my databases instead.
__________________
Aimoo - Affordable feature-packed remotely hosted message boards!
conkermaniac is offline
Reply With Quote
View Public Profile Visit conkermaniac's homepage!
 
Old 10-12-2002, 09:28 AM
Novice Talker

Posts: 8
winmsqladmin isnt a very user friendly program. At a first glance it seems like it only lets you view information about your server and database. There is no button or menu choice to create a database. I figured out how to make a database accidentally. I just right clicked in the area where you view your databases. very strange program. You can tell who ever made that program wasn't really a windows kinda guy. Now i would think that you would be able to edit the information in all the tables and such from winmysqladmin but so far I think you can only look at it. Oh well. I wish i grew up on Linux instead of windows. I'm so brainwashed in the ways of GUI. Well i'm trying to learn linux anyway, I have it on disk and all i need is another computer to put it on (the one i have now is just about full, plus i dont feel like dual booting, whoa i'm gettin a little off topic here)
whitchman is offline
Reply With Quote
View Public Profile
 
Old 10-12-2002, 12:19 PM
dk01's Avatar
Ultra Talker

Posts: 373
Location: Ames, IA
I would suggest using MysqlFront if you are having trouble with databases.
-dk
__________________
Did I help you? If so, be nice and throw me some TP
dk01 is offline
Reply With Quote
View Public Profile Visit dk01's homepage!
 
Reply     « Reply to Learning PHP/MySQL
 

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

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




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.17076 seconds with 12 queries