Jump to content


Photo

Error :( what i Do wrong?


  • Please log in to reply
3 replies to this topic

#1 scheols

scheols
  • Members
  • PipPipPip
  • Advanced Member
  • 113 posts

Posted 24 June 2006 - 07:42 PM

heres my database file

db.php

<?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();
}
?>

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

heres my form :

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

Dont Piss me Off today

#2 Koobi

Koobi
  • Staff Alumni
  • Advanced Member
  • 419 posts
  • LocationColombo, Sri Lanka | South Asia

Posted 24 June 2006 - 07:52 PM

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

#3 scheols

scheols
  • Members
  • PipPipPip
  • Advanced Member
  • 113 posts

Posted 24 June 2006 - 08:20 PM

line 36 is

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

Dont Piss me Off today

#4 Koobi

Koobi
  • Staff Alumni
  • Advanced Member
  • 419 posts
  • LocationColombo, Sri Lanka | South Asia

Posted 24 June 2006 - 08:28 PM

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:
$request = "INSERT INTO buser values(NULL,\"$user\",\"$pass\",\"pass2\",\"email\",\"email2\")";

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


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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users