Results 1 to 2 of 2
Thread: Php sign up help !
-
April 30th, 2012, 09:31 AM #141Registered User
postsPhp sign up help !
hello good day to everone, anyway im a newbie on php, and im creating a website which requires sign up or registration before entering the site, anyway Im using MySQL for back-end(database). hope u can help me guys, thanks in advance... heres my code but it has an error " Warning: Wrong parameter count for mysql_connect() in C:\wamp\www\webtry\check_signup.php on line 28
Cannot connect to database "
This is my code :
<html>
<title>
</title>
<head>
<link rel="stylesheet" type="text/css" href="layout.css" />
<link rel="shortcut icon" href="clown.png" />
</head>
<body>
<?php
$host= "localhost";
$username="";
$password="";
$age="";
$fname="";
$lname="";
$id= "";
$db_name="test";
$tbl_name="member";
mysql_connect("$host", "$username", "$password", "$fname", "$lname", $age) or die("Cannot connect to database");
mysql_select_db("$db_name") or die ("Cannot select DB!");
$myfirstname=$_POST['myfirstname'];
$mylastname=$_POST['mylastname'];
$myage= $_POST['myage'];
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$check= "SELECT * FROM $tbl_name WHERE username= '$myusername' and password= '$mypassword' AND
fname= '$myfirstname' AND lname= '$mylastname' AND age= $myage ";
$qry= mysql_query($check) or die ("Could not match");
$num_rows = mysql_num_rows($qry);
if($num_rowns !=0)
{
echo "Sorry, the username $myusername is already taken.";
exit;
}
else
{
$insert = mysql_query("INSERT INTO $tble_name VALUES('NULL','$myusername', '$mypassword', '$myfirstname', '$mylastname', '$myage'")
or die("Could not insert data");
}
?>
</body>
</html>Last edited by raphaelle; April 30th, 2012 at 09:35 AM. Reason: Forgot my codes.
-
May 28th, 2012, 06:33 AM #2233Registered User
postsHi, Its simple... the error says
"Warning: Wrong parameter count for mysql_connect() "
what that means is that you have the wrong number of paramers in the function mysql_connect().
it only requires
mysql_connect("host", "username", "password")
So u need to remove your extra vars such as "$fname", "$lname", $age)"... and then try it...
REF: http://www.phpeasystep.com/mysql/4.html
Hope this helps

Reply With Quote


Bookmarks