Jump to content

I KNOW ITS A SIMPLE MISTAKE!!! WERE IS IT -_-


duffman014

Recommended Posts

I'm making just a basic registration script... i want it to compare the passwords to see if they are the same? when i run it. i get this error

 

Parse error: syntax error, unexpected T_ELSE in D:\Hosting\4688039\html\test1\registration.php on line 21

 

i think i just wrote the if statment incorrectly.... if so could u please show me what i did wrong..

 

<?php

$host="********"; // Host name 
$username="*****"; // Mysql username 
$password="****"; // Mysql password 
$db_name="*****"; // Database name 
$tbl_name="registration"; // Table name 

mysql_connect ("$host, $username, $password") or die ("cannot connect");
mysql_select_db ("$db_name")or die("cannot select DB");

$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$verifypassword=$_POST['verifypassword'];
$email=$_POST['email'];

IF ($mypassword == $verifypassword)
{
header("location: registration.php")

else
{
echo  "finaly got one "
}
}

$sql="INSERT INTO $tbl_name(myusername, mypassword, email)VALUES('$myusername', '$password', '$email')";
$result=mysql_query($sql);

?>

Link to comment
Share on other sites

bad brackets and missing semi-colons

 

<?php

IF ($mypassword == $verifypassword)
{
header("location: registration.php");
}
else
{
echo  "finaly got one ";
}

?>

 

 

still getting this error?????

 

 

Parse error: syntax error, unexpected '}' in D:\Hosting\4688039\html\test1\registration.php on line 21

Link to comment
Share on other sites

Did you copy/paste his code?  I ask because there is no line 21 and there is no included file in his code.

 

<?php

IF ($mypassword == $verifypassword)
{
header("location: registration.php");
}
else
{
echo  "finaly got one ";
}

?>

 

If you are still having the problem post up the full code for registration.php

Link to comment
Share on other sites

i do not see any other syntax errors in the code you posted.  post the full page or show us exactly which line is line 21

 

i fixed the if statment.. but now it just keeps saying that i cant connect to my database.... i dont understand one second it'll connect but why does it say it wont connect.... OMG so confused.. HELP

 

<?php

$host="********"; // Host name 
$username="*****"; // Mysql username 
$password="****"; // Mysql password 
$db_name="*****"; // Database name 
$tbl_name="registration"; // Table name 

mysql_connect ("$host, $username, $password") or die ("cannot connect");
mysql_select_db ("$db_name")or die("cannot select DB");

$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$verifypassword=$_POST['verifypassword'];
$email=$_POST['email'];


IF ($mypassword == $verifypassword)
{
header("location: registration.php");
}
else
{
echo  "finaly got one ";
}

?>

Link to comment
Share on other sites

Maybe there is an issue with the database server connection, ie the database server isn't reliable?

 

Try changing

// Table name

 

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

 

to

 

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

 

This will give you the actual mySQL error.

Link to comment
Share on other sites

the connect statement takes three parameters.  With the way your quotes are set up, you have it sent as a single string parameter. You do not need quotes around variables.

 

Also, it returns a parameter

 

Use a color-coded editor so you can see silly mistakes like this.  Ive corrected a couple things so far

<?php
$connection = mysql_connect($host, $username, $password) or die ("cannot connect");
mysql_select_db ($db_name,$connection)or die("cannot select DB");

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.