Jump to content

Archived

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

scheols

Error :( what i Do wrong?

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]

Share this post


Link to post
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 :)

Share this post


Link to post
Share on other sites
line 36 is

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

Share this post


Link to post
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 :)

Share this post


Link to post
Share on other sites

×

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.