Jump to content

Web Host Login Error.


shreyaskudav

Recommended Posts

I am getting an error:

Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'http' (1) in /home/u657647882/public_html/checklogin.php on line 9cannot connect

why is this happening..? Its occurring while login on my web host.

Link to comment
Share on other sites

This should be in the SQL section I believe.Also please post the relevant code that is causing this error.

Link to comment
Share on other sites

What host name are you using for your mysql_connect() function?It shouldn't contain http://, just the domain of the server, such as "sql.myhost.com" instead of "http://sql.myhost.com"

Link to comment
Share on other sites

<?php$host="localhost"; // Host name$username=""; // Mysql username$password=""; // Mysql password$db_name="test"; // Database name$tbl_name="members"; // Table name// Connect to server and select databse.mysql_connect("$host", "$username", "$password")or die("cannot connect");mysql_select_db("$db_name")or die("cannot select DB");// username and password sent from form$myusername=$_POST['myusername'];$mypassword=$_POST['mypassword'];// To protect MySQL injection (more detail about MySQL injection)$myusername = stripslashes($myusername);$mypassword = stripslashes($mypassword);$myusername = mysql_real_escape_string($myusername);$mypassword = mysql_real_escape_string($mypassword);$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";$result=mysql_query($sql);// Mysql_num_row is counting table row$count=mysql_num_rows($result);// If result matched $myusername and $mypassword, table row must be 1 rowif($count==1){// Register $myusername, $mypassword and redirect to file "login_success.php"session_register("myusername");session_register("mypassword");header("location:login_success.php");}else {echo "Wrong Username or Password";}?>

This was the script i used..

Link to comment
Share on other sites

is this code working now?..i cant see host been set to any http..its been set to localhost which looks like ok.btwyou dont need to quote the parameter here.

mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_connect($host, $username, $password)or die("cannot connect");

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...