Jump to content

Recommended Posts

??? ??? ??? ??? ??? ??? ???

 

Hi guys,

 

Maybe someone can help me because I am totally confused. What is a T_IF error, and it says that its on line 37 but I just don't see the problem.

 

Any help would be greatly appreciated.

Here is My Code!

<?php
$database_connect = mysql_connect("mysql.thegayestwebsiteever.com","thegayestever","emit098nice054");
if (!$database_connect)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("usrmgmt", $database_connect);

$entryUsername = username;
$sql = "SELECT * FROM user_info WHERE username = '$entryUsername'";
$result = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($result))
   {
   die("That UserName already exists in our system! Please enter another username");
}
Else
{
$sql="INSERT INTO user_info(first_name, last_name, billing_address, line_2, city, state_province, zip_postal_code, country, card_type, cc_num, cvv2, exp_month, exp_year, email_address, phone, username, password)
VALUES
('$_POST[first_name]', '$_POST[last_name]', '$_POST[billing_address]', '$_POST[line_2]', '$_POST[city]', '$_POST[state_province]', '$_POST[zip_postal_code]', '$_POST[country]', '$_POST[card_type]', '$_POST[cc_num]', '$_POST[cvv2]', '$_POST[exp_month]', '$_POST[exp_year]', '$_POST[email_address]', '$_POST[phone]', '$_POST[username]', '$_POST[password]')";
}
if (!mysql_query($sql,$database_connect))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($database_connect);

if (!mysql_query($sql,$db_con_usrmgmt))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($database_connect);

$db_
if (!database_connect)
{
die('Could not connect: ' . mysql_error());
}
Else
mysql_select_db("login_script", $db_con_login_script);
{
$sql="INSERT INTO login_script(First_name, Last_name, User_name, Password)
VALUES
('$_POST[First_name]', '$_POST[Last_name]', '$_POST[username]', '".md5($_POST['Password'])."')";
}
if (!mysql_query($sql,$db_con_login_script))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($db_con_login_script);
?>

 

 

Thanks Guys,

dt_gry.

Link to comment
https://forums.phpfreaks.com/topic/127332-unexpected-t_if-error-on-line-37/
Share on other sites

couple lines down too:

<?php
Else
mysql_select_db("login_script", $db_con_login_script);
{
$sql="INSERT INTO login_script(First_name, Last_name, User_name, Password)
VALUES
('$_POST[First_name]', '$_POST[Last_name]', '$_POST[username]', '".md5($_POST['Password'])."')";
}
?>

 

I don't know what you are trying to do here.

I am copying those fields from the form to the database and encrypting the password to md5.

 

Okay I fixed that error now I am getting "Unexpected T_Variable on line 42. I know usually this means that you have forgotten to put a ; at the end of a statement but I have one at the end of that line and have looked and don't see where I am missing one.

 

Here is the code

<?php
$database_connect = mysql_connect("mysql.thegayestwebsiteever.com","thegayestever","emit098nice054");
if (!$database_connect)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("usrmgmt", $database_connect);

$entryUsername = username;
$sql = "SELECT * FROM user_info WHERE username = '$entryUsername'";
$result = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($result))
   {
   die("That UserName already exists in our system! Please enter another username");
}
Else
{
$sql="INSERT INTO user_info(first_name, last_name, billing_address, line_2, city, state_province, zip_postal_code, country, card_type, cc_num, cvv2, exp_month, exp_year, email_address, phone, username, password)
VALUES
('$_POST[first_name]', '$_POST[last_name]', '$_POST[billing_address]', '$_POST[line_2]', '$_POST[city]', '$_POST[state_province]', '$_POST[zip_postal_code]', '$_POST[country]', '$_POST[card_type]', '$_POST[cc_num]', '$_POST[cvv2]', '$_POST[exp_month]', '$_POST[exp_year]', '$_POST[email_address]', '$_POST[phone]', '$_POST[username]', '$_POST[password]')";
}
if (!mysql_query($sql,$database_connect))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($database_connect);

if (!mysql_query($sql,$db_con_usrmgmt))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($database_connect);

$db_con_login_script = mysql_connect("mysql.thegayestwebsiteever.com","thegayestever","emit098nice054);
if (!database_connect)
{
die('Could not connect: ' . mysql_error());
}
Else
mysql_select_db("login_script", $db_con_login_script);
{
$sql="INSERT INTO login_script(First_name, Last_name, User_name, Password)
VALUES
('$_POST[First_name]', '$_POST[Last_name]', '$_POST[username]', '".md5($_POST['Password'])."')";
}
if (!mysql_query($sql,$db_con_login_script))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($db_con_login_script);
?>

 

Thanks for the help guys

dt_gry

Get yourself an editor that highlights lines and quote. It will be a big help.

 

You are missing a quote in this line

<?php
$db_con_login_script = mysql_connect("mysql.thegayestwebsiteever.com","thegayestever","emit098nice054);
?>

 

Also, this set of lines doesn't make any sense:

<?php
if (!database_connect)
{
die('Could not connect: ' . mysql_error());
}
Else
mysql_select_db("login_script", $db_con_login_script);
{
$sql="INSERT INTO login_script(First_name, Last_name, User_name, Password)
VALUES
('$_POST[First_name]', '$_POST[Last_name]', '$_POST[username]', '".md5($_POST['Password'])."')";
}
?>

Since you have a single line following the "else" and then lines within "{ }"

 

Ken

Okay I have fixed all the issues mentioned above and the code should now make sense.

 

Here is a link to what I have been working on.

http://www.phpfreaks.com/forums/index.php/topic,214895.0.html

 

Now I have yet another problem, when the code is processed and it connects to login_script and table members it only inserts the passwd and not the firstname lastname and user. There is an auto-incremented integer in field one but I have never had a problem with it not being designated before.

 

Here is the new code

<?php
$database_connect = mysql_connect("mysql.thegayestwebsiteever.com","thegayestever","emit098nice054");
if (!$database_connect)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("usrmgmt", $database_connect);

$entryUsername = username;
$sql = "SELECT * FROM user_info WHERE username = '$entryUsername'";
$result = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($result))
   {
   die("That UserName already exists in our system! Please enter another username");
}
Else
{
$sql="INSERT INTO user_info(first_name, last_name, billing_address, line_2, city, state_province, zip_postal_code, country, card_type, cc_num, cvv2, exp_month, exp_year, email_address, phone, username, password)
VALUES
('$_POST[first_name]', '$_POST[last_name]', '$_POST[billing_address]', '$_POST[line_2]', '$_POST[city]', '$_POST[state_province]', '$_POST[zip_postal_code]', '$_POST[country]', '$_POST[card_type]', '$_POST[cc_num]', '$_POST[cvv2]', '$_POST[exp_month]', '$_POST[exp_year]', '$_POST[email_address]', '$_POST[phone]', '$_POST[username]', '$_POST[password]')";
}
if (!mysql_query($sql,$database_connect))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($database_connect);


$db_con_login_script = mysql_connect("mysql.thegayestwebsiteever.com","thegayestever","emit098nice054");
if (!database_connect)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("login_script", $db_con_login_script);

$sql="INSERT INTO members(firstname, lastname, login, passwd)
VALUES
('$_POST[First_name]', '$_POST[Last_name]', '$_POST[username]', '".md5($_POST['Password'])."')";

if (!mysql_query($sql,$db_con_login_script))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($db_con_login_script);
?>

 

Thanks guys,

dt_gry

Comment: Consider using SHA1 over md5, it is a better hasher. If you have the choice, you might as well go with the SHA1.

 

Lies, you will not put down the MD5! To be honest it doesn't matter, salt your hashes and use whatever you want, the difference isn't really that great.

Lol, just from reading I found several sources stating that is is better. For one, it took at least twice as long to find collisions with SHA1. But yes, if you Salt with like 16 characters of randomness, you should be doing pretty well even with md5. We are talking about milliseconds per character, so just might as well make it the data to be hashed huge with the salt.

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.