Jump to content

Error :( what i Do wrong?


scheols

Recommended Posts

heres my database file

db.php

[code]
<?php

$user = $_POST["username"];
$pass = $_POST["password"];
$pass2 = $_POST["password2"];
$email = $_POST["email"];
$email2 = $_POST["email2"];


//Get The Database
$db_connection = mysql_connect("localhost", $_POST["dbuname"], $_POST[ "dbpass"]);

/*--------------------------------------------------------------------------------------------------*/

//Choose database or return error
@mysql_select_db($_POST["dbname"]) or die( "unable to select database");

/*--------------------------------------------------------------------------------------------------*/

$check = mysql_query("select user name from users where username=\"$user\"");

/*--------------------------------------------------------------------------------------------------*/

$returned = mysql_fetch_array($check);

/*--------------------------------------------------------------------------------------------------*/

if(!empty($returned))
    {
        header("Location: someerrorpage.php");
    mysql_close($link);
    Die();
}
else
$pass=md5($pass);
$request = "INSERT INTO buser values(NULL,"$user","$pass","pass2","email","email2")";

/*--------------------------------------------------------------------------------------------------*/
$results = mysql_query($request);
/*--------------------------------------------------------------------------------------------------*/
if($results)
    {
        header("Location: thxforj.php");
}
else    {
        header("Location: errorjoin.php");
}
mysql_close($link);
Die();
}
?>
[/code]

said i got a:Parse error: syntax error, unexpected T_VARIABLE in /home/scheols/public_html/db.php on line 36

heres my form :

[code]
<HTML>
<BODY>
<form action="db.php"method="post">
DataBase Name:<input type="text" name="dbname">
<br>User Name:    <input type="text" name="dbuname">
<br>DB User Password:<input type="text" name="dbpass">
<br><input type="submit" value="Register" name="submit">
</form>
</BODY>
</HTML>
[/code]
Link to comment
Share on other sites

it's funny..T_VARIABLE is to do with variable names...but to me it seems like you're missing a brace...because your else (before the $pass=md5($pass);) lacks an opening brace but at the end of the PHP you have a closing brace.

and it would be best if you told us what line 36 was...especially because i'm not really into the whole counting thing :)
Link to comment
Share on other sites

that would be because you use double quotes as delimiters (at the beginning and end of the SQL to tell PHP that those are the bounds of the SQL) and you use double quotes within the query as well and PHP gets confused as to which is what since it's only a program that follows coded instructions.

you have two options, i prefer the latter:
[code]
$request = "INSERT INTO buser values(NULL,\"$user\",\"$pass\",\"pass2\",\"email\",\"email2\")";
[/code]

[code]
$request = "INSERT INTO buser values(NULL,'$user','$pass','pass2','email','email2')";
[/code]


why do i prefer the latter? because it's easier to read and is probably fractionally faster than the former.


hope that helped :)



:edit:
also, don't forget the missing brace i mentioned in my previous post :)
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.