Jump to content


mysql connect

  • Please log in to reply
3 replies to this topic

#1 wernervantonder

  • Members
  • PipPip
  • Member
  • 17 posts

Posted 14 September 2006 - 07:14 AM

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

#2 Zane

  • Administrators
  • Advanced Member
  • 4,134 posts

Posted 14 September 2006 - 07:57 AM

put the word localhost in double quotes


btn_donate_SM.gif Want to thank me? Contribute to my PayPal piggy-bank


#3 Daniel0

  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 14 September 2006 - 08:01 AM

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.

#4 wildteen88

  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 14 September 2006 - 10:11 AM

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.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users