Basic Help for mysql_connect

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
thawfeekyahya
Forum Newbie
Posts: 2
Joined: Wed Jan 13, 2010 6:05 am

Basic Help for mysql_connect

Post 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.
Renier
Forum Newbie
Posts: 5
Joined: Wed Jan 13, 2010 1:41 am

Re: Basic Help for mysql_connect

Post by Renier »

Host is the ip address or host name.

Username and password is sql's username and password
aravona
Forum Contributor
Posts: 347
Joined: Sat Jun 13, 2009 3:59 pm
Location: England

Re: Basic Help for mysql_connect

Post 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.
thawfeekyahya
Forum Newbie
Posts: 2
Joined: Wed Jan 13, 2010 6:05 am

Re: Basic Help for mysql_connect

Post 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?
aravona
Forum Contributor
Posts: 347
Joined: Sat Jun 13, 2009 3:59 pm
Location: England

Re: Basic Help for mysql_connect

Post 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.
Last edited by aravona on Wed Jan 13, 2010 7:26 am, edited 1 time in total.
Renier
Forum Newbie
Posts: 5
Joined: Wed Jan 13, 2010 1:41 am

Re: Basic Help for mysql_connect

Post by Renier »

Also enable show errors in the php.ini file
Post Reply