mindapolis Posted October 4, 2011 Share Posted October 4, 2011 what 's wrong with the following code ? I declared the variables in the lines above this code. $connetion = mysql_connect($host $username $password) or die("connection could not be established"); Quote Link to comment Share on other sites More sharing options...
dougjohnson Posted October 4, 2011 Share Posted October 4, 2011 I think you need to separate your connection variables with commas. Quote Link to comment Share on other sites More sharing options...
mindapolis Posted October 4, 2011 Author Share Posted October 4, 2011 I already tried that, it didn't help ` Quote Link to comment Share on other sites More sharing options...
dougjohnson Posted October 4, 2011 Share Posted October 4, 2011 Try this? $db = mysql_connect($host, $username, password) or die("Could not connect: " . mysql_error()); mysql_select_db("dbname",$db) or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
awjudd Posted October 4, 2011 Share Posted October 4, 2011 what 's wrong with the following code ? I declared the variables in the lines above this code. $connetion = mysql_connect($host $username $password) or die("connection could not be established"); That is a syntax error ... It should be: $connetion = mysql_connect($host,$username,$password) or die("connection could not be established"); Other than that we need more information about the error you are getting. @dougjohnson - you are missing a $ in front of password. ~juddster Quote Link to comment Share on other sites More sharing options...
mindapolis Posted October 4, 2011 Author Share Posted October 4, 2011 now it 's saying Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'local host' (11004) in D:\Hosting\5246561\html\treats.php on line 14 connection could not be established Quote Link to comment Share on other sites More sharing options...
AltarofScience Posted October 4, 2011 Share Posted October 4, 2011 could you post the entire code, including what variables you declared? Quote Link to comment Share on other sites More sharing options...
awjudd Posted October 4, 2011 Share Posted October 4, 2011 localhost is 1 word not 2. ~juddster Quote Link to comment Share on other sites More sharing options...
fenway Posted October 4, 2011 Share Posted October 4, 2011 You need to read a PHP syntax manual. Quote Link to comment Share on other sites More sharing options...
mindapolis Posted October 4, 2011 Author Share Posted October 4, 2011 Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'local host' (11004) in D:\Hosting\5246561\html\treats.php on line 14 connection could not be established <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php $host = "localhost"; $username = "xxxxics"; $password = "xxxxxx'711"; $connection = mysql_connect($host,$username,$password) or die("connection could not be established"); ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
fenway Posted October 4, 2011 Share Posted October 4, 2011 That's not the code that's generating that error. Quote Link to comment Share on other sites More sharing options...
mindapolis Posted October 4, 2011 Author Share Posted October 4, 2011 umm, yes, this is the code that 's generating the error Quote Link to comment Share on other sites More sharing options...
fenway Posted October 4, 2011 Share Posted October 4, 2011 No, it's not -- "local host" is not the same as "localhost". Quote Link to comment Share on other sites More sharing options...
mindapolis Posted October 4, 2011 Author Share Posted October 4, 2011 I already changed that, it 's still giving me the same error. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php $host = "localhost"; $username = "xxxxxics"; $password = "xxxxxxx711"; $connection = mysql_connect($host,$username,$password) or die("connection could not be established"); ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
awjudd Posted October 4, 2011 Share Posted October 4, 2011 I disagree. You likely have 'local host' somewhere else. ~juddster Quote Link to comment Share on other sites More sharing options...
mindapolis Posted October 4, 2011 Author Share Posted October 4, 2011 no I don't Quote Link to comment Share on other sites More sharing options...
mikosiko Posted October 4, 2011 Share Posted October 4, 2011 2 options: 1) echo the variable $host before the the connect to check if you really have the value "localhost" 2) write again the line that read $host = "localhost" ... you could have a hidden character there. Quote Link to comment Share on other sites More sharing options...
mindapolis Posted October 4, 2011 Author Share Posted October 4, 2011 got it Quote Link to comment Share on other sites More sharing options...
awjudd Posted October 4, 2011 Share Posted October 4, 2011 Was it what we said (i.e. you had 'local host' somewhere?)? ~juddster Quote Link to comment Share on other sites More sharing options...
mindapolis Posted October 5, 2011 Author Share Posted October 5, 2011 no ,like I said it had nothing to do with the term "local host" Quote Link to comment Share on other sites More sharing options...
awjudd Posted October 5, 2011 Share Posted October 5, 2011 Then what was the issue? ~juddster Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.