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);

?>

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

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

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 ";
}

?>

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.

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");

Archived

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

×
×
  • 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.