Page 1 of 1

Basic Help for mysql_connect

Posted: Wed Jan 13, 2010 6:14 am
by thawfeekyahya
hello ,
i am looking for some to help me with this basic php function to connect with MySQL.
as i am new to php programming , i had tried to connect my php page with MySQL with mysql_connect function.but the browser says like this" HTTP 500 Internal server Error".I am using IIS on XP os. can any one explain me about this?


---->mysql_connect("host","username","passoword")

--->what is host??

--->what is the username??

--->what is the password??

when i have installed MySQL(5.0) it only asked me for password.it doesn't ask me about any user name.

Re: Basic Help for mysql_connect

Posted: Wed Jan 13, 2010 6:20 am
by Renier
Host is the ip address or host name.

Username and password is sql's username and password

Re: Basic Help for mysql_connect

Posted: Wed Jan 13, 2010 6:28 am
by aravona
you should be able to connect with:

mysql_connect("localhost","root","")
thawfeekyahya wrote:when i have installed MySQL(5.0) it only asked me for password
If its anything like the latest WAMP - you dont add a password just hit enter. Always best to try that first anyway - if you havent set up any username or password its a good chance there isnt one.

Re: Basic Help for mysql_connect

Posted: Wed Jan 13, 2010 7:06 am
by thawfeekyahya
I am trying to configure MySQL, IIS, and PHP to work together.
I have the following code:
<?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

// some code
?>



When I run it through IIS I get "HTTP 500 Internal Server Error".
When I run several other PHP scripts(that don't include mysql commands) through IIS they work fine.
Any ideas what could possibly be wrong?

Re: Basic Help for mysql_connect

Posted: Wed Jan 13, 2010 7:24 am
by aravona
(After some googling...)

If you are using Internet Explorer to view your code try going to Internet Options then Advanced and DESELECT 'Show friendly HTTP errors' then run the code again.

This should then show the full error from your server, hope this helps.

Re: Basic Help for mysql_connect

Posted: Wed Jan 13, 2010 7:25 am
by Renier
Also enable show errors in the php.ini file