Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am using the following code but there's some connection error and nothing seems to be working:


PHP
<?php

session_start();
$SESSION[Telephone_No]=[$Telephone_No];
$con=mysql_connect("localhost","root","mysql11");
mysql_connect("pvclub",$con);
$result=mysql_query("Select Telephone_No, Password from register where Telephone_No=\"$Telephone_No\"");
$temp=mysql_fetch_array($result);

if (mysql_num_rows($result)==0)
{
echo "Invalid Entry";
include("homepage.html");
}
else
{
if($temp['Password']==$Password)
{
session_start();
$SESSION['Telephone_No']=$Name;
include("login.php");
}
else
{
echo "Wrong Password";
include("homepage.html");
}
} 
?>
Posted
Comments
Uday P.Singh 20-Jul-12 9:40am    
what is the error message?

1 solution

There are many things that can go wrong while establishing a connection. Passwords may not match, the server may be down etc.

First make sure the mysql server is up and configured properly. Also that you are using the correct port. [3306 is the default port for Mysql 5] Make sure that your firewall is not blocking that port.

Consider using the "or die()" construct to print the error message. The "die" part will be executed if the connection fails. It will help to debug as to why the connection is failing.

PHP
mysql_connect("localhost", "admin", "1admin") or die(mysql_error());


Some links you may like to read:
Tutorial
Die manual
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900