943,717 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 3774
  • PHP RSS
Apr 27th, 2007
0

unable to connect PHP with Mysql

Expand Post »
I am new to PHP. I am trying to connect mysql with PHP with
mysql_connect but i m getting
"A link to the server could not be established"
I have used ODBC 3.51 driver for odbc and made connections with odbc with odbc_connect
but i don't know how to connect it with mysql_connect and fire mysql_-----queries.
Is there any specific driver for tht?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster
bhavna_816 is offline Offline
116 posts
since Sep 2006
Apr 27th, 2007
0

Re: unable to connect PHP with Mysql

Why are you using ODBC connction r u using windows machine or linux server ? Arey you use MYSQL database or other?
Reputation Points: 5
Solved Threads: 5
Junior Poster
vssp is offline Offline
197 posts
since Jul 2006
Apr 27th, 2007
0

Re: unable to connect PHP with Mysql

Click to Expand / Collapse  Quote originally posted by vssp ...
Why are you using ODBC connction r u using windows machine or linux server ? Arey you use MYSQL database or other?
I told tht i have used ODBC 3.51 driver and used odbc_connect and so on......... queries ....
but now i have to use mysql_connect and so on........ queries .
I have Windows Server 2003 Service Pack 1 version of windows.
Reputation Points: 10
Solved Threads: 0
Junior Poster
bhavna_816 is offline Offline
116 posts
since Sep 2006
Apr 27th, 2007
0

Re: unable to connect PHP with Mysql

Are you sure the server is running? (check the obvious first :-)

Also check the order of the arguments to mysql_connect - it's server, user, password. (I somehow manage to forget that every single time I use mysql, and PHP yells at me for it a lot :-)

If the mysql and web servers are on different computers, make sure there isn't a firewall blocking them (sounds like something Windows Firewall would do...)
Reputation Points: 17
Solved Threads: 5
Posting Whiz in Training
mmiikkee12 is offline Offline
274 posts
since Oct 2004
Apr 27th, 2007
0

Re: unable to connect PHP with Mysql

You do know you need to copy the mysql dlls from the mysql directory to the PHP one and point the PHP config file at them?

This is probably as in PHP5 they removed MySQL support (was in by deafult before)
Last edited by jbennet; Apr 27th, 2007 at 9:31 pm.
Moderator
Featured Poster
Reputation Points: 1764
Solved Threads: 574
Moderator
jbennet is offline Offline
16,505 posts
since Apr 2005
Apr 28th, 2007
0

Re: unable to connect PHP with Mysql

Once you have completed all the above you should use the following code to connect -

mysql_connect('HOSTNAME', 'USERNAME', 'PASSWORD');

if(mysql_error()) {
echo mysql_errno().'<BR>
mysql_error();
}
Reputation Points: 15
Solved Threads: 17
Junior Poster
phper is offline Offline
189 posts
since Nov 2006
Apr 28th, 2007
0

Re: unable to connect PHP with Mysql

Might be worthwhile doing an advanced search for all forum posts where i have posted as I member a while ago i posted a zip file constaining a whole load of PHP/MySQL example code like that.
Last edited by jbennet; Apr 28th, 2007 at 8:59 am.
Moderator
Featured Poster
Reputation Points: 1764
Solved Threads: 574
Moderator
jbennet is offline Offline
16,505 posts
since Apr 2005
Apr 29th, 2007
0

Re: unable to connect PHP with Mysql

Click to Expand / Collapse  Quote originally posted by jbennet ...
You do know you need to copy the mysql dlls from the mysql directory to the PHP one and point the PHP config file at them?

This is probably as in PHP5 they removed MySQL support (was in by deafult before)
you dont need to copy mysql dlls even in php 5 u just hav to add php folder and mysql folder to the windows path
Last edited by w_3rabi; Apr 29th, 2007 at 4:54 am.
Reputation Points: 18
Solved Threads: 9
Junior Poster
w_3rabi is offline Offline
160 posts
since Dec 2006
Apr 29th, 2007
0

Re: unable to connect PHP with Mysql

oh
Moderator
Featured Poster
Reputation Points: 1764
Solved Threads: 574
Moderator
jbennet is offline Offline
16,505 posts
since Apr 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: need help in php
Next Thread in PHP Forum Timeline: prev link





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC