473,714 Members | 2,505 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

connecting to db..

this seems pretty straight-forward.. got this code

$link = mysql_connect(' localhost:3306' , '<uid>', '<pswd>');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($li nk);

from here..
http://us2.php.net/function.mysql-connect

but can't connect, get this error:

Connect to db:
Warning: mysql_connect() [function.mysql-connect]: Can't connect to
MySQL server on 'localhost' (10061) in
C:\xampp\xampp\ htdocs\home\con n.php on line 19
Could not connect: Can't connect to MySQL server on 'localhost' (10061)

I connect to this same MySQL server from Tomcat w/no problem.. what is
issue here pls...
now on top of pg mentioned above, there this description:

resource mysql_connect ( [string server [, string username [, string
password [, bool new_link [, int client_flags]]]]] )

what does 'resource' refer to here pls... and where to do specify what
db to connect to... (in java you put db-name in same line where you
make the connection..)
(and don't you need a driver to connect, I use a JDBC driver to
connect w/Java..)

would very much appreciate some help.. thank you...

Frances

Jun 6 '06 #1
7 4053

disregard -- now all of a sudden can't connect from Java either.. I
don't get this.. I've been connecting successfully to db for over a
year from both Tomcat & java stand-alone classes, now all of a sudden am
trying to connect also from PHP and I can't connect at all..

when try to connect just from console get error:

ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)

what is this.. what is 10061.. :(

is it really not possible then to connect to one MySQL server from diff
web servers? (I don't think so..) I want to set up my machine so can
connect to same MySQL server from Tomcat, IIS, PHP.. (the port thing is
also a big pain and don't know if will be able to pull this off..) thank
you very much..

Frances

Frances wrote:
this seems pretty straight-forward.. got this code

$link = mysql_connect(' localhost:3306' , '<uid>', '<pswd>');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($li nk);

from here..
http://us2.php.net/function.mysql-connect

but can't connect, get this error:

Connect to db:
Warning: mysql_connect() [function.mysql-connect]: Can't connect to
MySQL server on 'localhost' (10061) in
C:\xampp\xampp\ htdocs\home\con n.php on line 19
Could not connect: Can't connect to MySQL server on 'localhost' (10061)

I connect to this same MySQL server from Tomcat w/no problem.. what is
issue here pls...
now on top of pg mentioned above, there this description:

resource mysql_connect ( [string server [, string username [, string
password [, bool new_link [, int client_flags]]]]] )

what does 'resource' refer to here pls... and where to do specify what
db to connect to... (in java you put db-name in same line where you
make the connection..)
(and don't you need a driver to connect, I use a JDBC driver to
connect w/Java..)

would very much appreciate some help.. thank you...

Frances

Jun 6 '06 #2
Rik
Frances wrote:
this seems pretty straight-forward.. got this code

$link = mysql_connect(' localhost:3306' , '<uid>', '<pswd>');
Do you need the port here? And I assume your username & password are
correct?
What happens if you:
$link = mysql_connect(' localhost', 'your_username' , 'your_password' );

If you want to connect by TCP/IP use 127.0.0.1 instead of localhost.
now on top of pg mentioned above, there this description:

resource mysql_connect ( [string server [, string username [, string
password [, bool new_link [, int client_flags]]]]] )

what does 'resource' refer to here pls...
www.php.net > manual > types > resource:
http://www.php.net/manual/en/languag...s.resource.php

A resource is a special variable, holding a reference to an external
resource.
and where to do specify what
db to connect to... (in java you put db-name in same line where you
make the connection..)
mysql_select_db ('db_name', $link);
(and don't you need a driver to connect, I use a JDBC driver to
connect w/Java..)


Mostly it's enabled by default in PHP4, PHP5 it's not, details:
http://www.php.net/manual/en/ref.mysql.php

Grtz

--
Rik Wasmus
Jun 6 '06 #3
Rik
Frances wrote:
when try to connect just from console get error:

ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost'
(10061)
what is this.. what is 10061.. :(
Try to restart your MySQL-server, if that doesn't work: GOOGLE:
http://www.google.com/search?q=mysql+%22ERROR+2003%22

is it really not possible then to connect to one MySQL server from
diff web servers? (I don't think so..) I want to set up my machine
so can connect to same MySQL server from Tomcat, IIS, PHP.. (the port
thing is also a big pain and don't know if will be able to pull this
off..) thank you very much..


It should not be any problem to connect dozens of times to the same MySQL
database from all kinds of locations, servers, applications.

Rushing into things will give you these kind of errors. You do ask many
questions. Now, take a break, look at some documentation, google the exact
questions you have, and discover a wealth of ready information.

Grtz,
--
Rik Wasmus
Jun 6 '06 #4
Rik wrote:
Frances wrote:
when try to connect just from console get error:

ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost'
(10061)
what is this.. what is 10061.. :(

Try to restart your MySQL-server, if that doesn't work: GOOGLE:
http://www.google.com/search?q=mysql+%22ERROR+2003%22


I did do a google search earlier.. searched for the same thing...
I did find one or two fora where it says to restart the server, but
don't know how you do that.. it says in my book (oreilly) to start the
server to run $ bin/safe_mysqld --user=mysql &... don't see a file
called 'safe_mysqld in C:\Program Files\MySQL\MyS QL Server 4.1\bin..
(why does installation not come with a list of what each executable
in bin dir does? there are lots of them..)

I tried to open mysql.exe earlier, saw a glimpse of a shell window,
which then disappeared.. could this have caused the problem.. it says
in manual to run 'bin\mysqld --console' I navigated to bin dir and did

mysqld --console get error.. then did:
mysqld.exe --console also get error....

manual says to run bin\mysqld -- there's no such file in bin dir.. this
is frustrating.. (still don't know what happened.. why after having
used this server for about a year with no problems would I need to
restart server all of a sudden..)

ok, I think I need to switch to mysql newsgroup.. what a pain.. either
way thank you for your help..

Frances

Jun 7 '06 #5

| manual says to run bin\mysqld -- there's no such file in bin dir.. this
| is frustrating.. (still don't know what happened.. why after having
| used this server for about a year with no problems would I need to
| restart server all of a sudden..)

Use the XAMPP Control Applet, and click on the MySQL START button ;-)

(you are still using XAMPP?). By-the-way, check earlier thread for more.

D.
Jun 7 '06 #6
Virginner wrote:
| manual says to run bin\mysqld -- there's no such file in bin dir.. this
| is frustrating.. (still don't know what happened.. why after having
| used this server for about a year with no problems would I need to
| restart server all of a sudden..)

Use the XAMPP Control Applet, and click on the MySQL START button ;-)

(you are still using XAMPP?). By-the-way, check earlier thread for more.

D.


Virninner, thank you for yr response.. I was trying to connect not to
MySQL that came w/xampp but to my 4.1 installation that I've been using
with java for over a year (I want to set everything up so I can connect
to same db with Tomcat/java, IIS, PHP.. but not getting very far for
now....;) now cannot connect to db at all, I mean to db I've been using
for a while, since before I installed xampp.. never had a problem w/it
before...

when try to connect just to console get error:

ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)

(do you think it has to do w/MySQL installation that came with XAMPP
(although I have uninstalled XAMPP completely by now.... want to
install it again at some point (I think it's still simpler than
installing and configuring Apache and
http://us2.php.net/downloads.php...) separately..) but don't know if
it's xampp that screwed my MySQL server I had installed... oh brother,
don't know what to do.. thank you for your help...
Jun 7 '06 #7
| ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)

.... means simply that the server is not running....

if it was running, you'd get an error message from the server, like pass
wrong or something.

CRTL-ALT-DEL, open task manager and look for it!!!

D.


Jun 7 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3635
by: Google Mike | last post by:
After a lot of thought and research, and playing with FreeTDS and InlineTDS, as well as various ODBC connections, I have determined that the fastest and cheapest way to get up and going with PHP on Linux, connecting to MS SQL Server, unless it was already pre-installed by your Linux installation, is to build your own multithreaded TCP socket server on Windows and connect to it through the socket API in PHP on Linux (if you have installed...
2
3222
by: Ramir Santos | last post by:
my analysis server is hosted on a win2k server with IIS, the hosting page is on another machine. I have followed everything as per MS KB article and I could not connect through the analysis server using http. i have similar implementation on my dev machine but the main difference is my OLAP is on top of winxp. i just wanted to know if i am missing any other setting not specified on the MS KB article on how to implement OLAP cube through...
4
2384
by: TP | last post by:
Hi, This is probably my 7th post of the day. not spamming, just want to get the questions out, so that I can find the answers and post them back or some good soul can help me out. Right now I am using DB2 connect version 7.2 to connect to db2 version 7.1.1 on os390/zos. Could I use a third party driver to do this? What would you recommend and is connecting to db2 on the mainframe a lot different than connecting to db2 on the pc?
12
2785
by: Ann Marinas | last post by:
Hi all, I would like to ask for some help regarding separating the asp.net webserver and the sql server. I have created an asp.net application for a certain company. Initially, we installed both the iis and sql server in a single machine. Not too long ago, the machine had some hardware problems, and management has decided to purchase new servers, for both asp.net and sql server.
3
2242
by: Jeremy Dillinger | last post by:
I am trying to design a program that will use data from a MySQL database. Currently all the data is being used with PHP scripts from a website. I am also trying to build a software solution that can use the same data. I have gone through all the data connectors in Visual Basic.net and none of them have the options for connecting to MySQL. Does anybody know how I would go about doing this? Thanks in advance! Jeremy
0
3055
by: NewsReader | last post by:
Hello, I have been looking around the net for a script to help me connect to and help gather information from Cisco routers/switches. I have pieced together a couple of different scripts from various different sources. I am having issue when connecting to Cisco devices. For some reason the scripts timesout/stops working just after the connection section of the script. It does not give me a confirmation of completeion nor does it give me...
0
2035
by: cj.snead | last post by:
Hello, I am having trouble connecting to a remote named instance of SQL Server via Pocket PC. I have had absolutely no luck connecting with VS 2005 (even to a default instance), so I wen't back to VS .NET 2003 (I had success doing this a while back). I am trying to connect to a named instance of SQL. This is where I think my problem is. My app errors out at the Connection.Open(); command. Here is my connection string:
0
1542
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, I've my win32 application which connecting to my sql database. till now i used MSDE as my database and now i want to upgrade to sql express 2005. after the upgrade i tried to connect to the database and couldn't. i keep getting an error which saying that database doesn't exists or access is denied. is there something diffrent between connecting to MSDE and connecting to sql express 2005 ? here with my connection string.
10
15951
by: mairhtin o'feannag | last post by:
Hello, I'm having problems connecting to my new v9 db box. The pertinent information is below: DB2_db2inst1 60000/tcp DB2_db2inst1_1 60001/tcp DB2_db2inst1_2 60002/tcp DB2_db2inst1_END 60003/tcp
0
2005
by: aboutjav.com | last post by:
Hi, I need some help. I am getting this error after I complete the asp.net register control and click on the continue button. It crashed when it tries to get it calls this Profile property ((string)(this.GetPropertyValue("Address1")));
0
8704
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9307
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9170
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7946
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6627
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5943
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4715
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2514
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2105
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.