Jump to content

Archived

This topic is now archived and is closed to further replies.

wernervantonder

mysql connect

Recommended Posts

Hi there i am a newbie in php and allready i find it very intresting! you might see me around here often. so my first question is this:

My database does not connect when i use the line: mysql_connect(localhost,$username,$password);
i have se my $username and $password vairiables and assure that it is correct. mysql is running alongside my apache server. i can view php pages via http://localhost/.

what did i do wrong when the error refrences to this line (....mysql_connect(localhost,$username,$password);......)
and tells me that there is a parsing error.?

Thanks in advance Werner

Share this post


Link to post
Share on other sites
put the word localhost in double quotes

mysql_connect("localhost",$username,$password);

Share this post


Link to post
Share on other sites
You need to put everything in either single-quotes or double-quotes. The only types where it's not necessary is integers and floating numbers. If it's a boolean then there may not be quotes around it.

Share this post


Link to post
Share on other sites
Could you post the actuall error message here and the code you are using here too.

Also @Daniel0 you do not need to put quotes around variables, floats, booleans etc.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.