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?

Why are you using ODBC connction r u using windows machine or linux server ? Arey you use MYSQL database or other?

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.

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...)

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)

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();
}

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.

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

oh

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.