unable to connect PHP with Mysql

Reply

Join Date: Sep 2006
Posts: 116
Reputation: bhavna_816 is an unknown quantity at this point 
Solved Threads: 0
bhavna_816 bhavna_816 is offline Offline
Junior Poster

unable to connect PHP with Mysql

 
0
  #1
Apr 27th, 2007
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?
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 197
Reputation: vssp has a little shameless behaviour in the past 
Solved Threads: 5
vssp vssp is offline Offline
Junior Poster

Re: unable to connect PHP with Mysql

 
0
  #2
Apr 27th, 2007
Why are you using ODBC connction r u using windows machine or linux server ? Arey you use MYSQL database or other?
Thanks
VSSP
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 116
Reputation: bhavna_816 is an unknown quantity at this point 
Solved Threads: 0
bhavna_816 bhavna_816 is offline Offline
Junior Poster

Re: unable to connect PHP with Mysql

 
0
  #3
Apr 27th, 2007
Originally Posted by vssp View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 274
Reputation: mmiikkee12 is an unknown quantity at this point 
Solved Threads: 5
mmiikkee12's Avatar
mmiikkee12 mmiikkee12 is offline Offline
Posting Whiz in Training

Re: unable to connect PHP with Mysql

 
0
  #4
Apr 27th, 2007
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...)
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 16,251
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 540
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator

Re: unable to connect PHP with Mysql

 
0
  #5
Apr 27th, 2007
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.
If i am helpful, please give me reputation points.
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 187
Reputation: phper is an unknown quantity at this point 
Solved Threads: 15
phper's Avatar
phper phper is offline Offline
Junior Poster

Re: unable to connect PHP with Mysql

 
0
  #6
Apr 28th, 2007
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();
}
If my post is useful please add to my reputation.
Thanks.

Ajtrichards Web Solutions | http://www.ajtrichards.co.uk
Retenovate | http://www.retenovate.com
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 16,251
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 540
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator

Re: unable to connect PHP with Mysql

 
0
  #7
Apr 28th, 2007
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.
If i am helpful, please give me reputation points.
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 160
Reputation: w_3rabi is an unknown quantity at this point 
Solved Threads: 9
w_3rabi's Avatar
w_3rabi w_3rabi is offline Offline
Junior Poster

Re: unable to connect PHP with Mysql

 
0
  #8
Apr 29th, 2007
Originally Posted by jbennet View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 16,251
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 540
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator

Re: unable to connect PHP with Mysql

 
0
  #9
Apr 29th, 2007
oh
If i am helpful, please give me reputation points.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC