...

View Full Version : problem with my register code



googleit
09-01-2006, 06:25 PM
hmm
why do i get this erro when i run this code?


Parse error: parse error, unexpected $ in /home/content/b/r/a/site/html/Coding zone/register.php on line 47

this is my code can you see any errors?

mysql_connect("host", "username", "pass") or die(mysql_error());
mysql_select_db("dbname") or die(mysql_error());


if (isset($_POST['submit'])) {

if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] ) {
die('You did not complete all of the required fields');
}


if (!get_magic_quotes_gpc()) {
$_POST['username'] = addslashes($_POST['username']);
}
$usercheck = $_POST['username'];
$check = mysql_query("SELECT username FROM users WHERE username = '$usercheck'")
or die(mysql_error());
$check2 = mysql_num_rows($check);


if ($check2 != 0) {
die('Sorry, the username '.$_POST['username'].' is already in use.');
}

if ($_POST['pass'] != $_POST['pass2']) {
die('Your passwords did not match.');
}


$_POST['pass'] = md5($_POST['pass']);
if (!get_magic_quotes_gpc()) {
$_POST['pass'] = addslashes($_POST['pass']);
$_POST['username'] = addslashes($_POST['username']);
}


$insert = "INSERT INTO users (username, password)
VALUES ('".$_POST['username']."', '".$_POST['pass']."')";
$add_member = mysql_query($insert);

musher
09-01-2006, 06:38 PM
Which line is line 47 in your code (post line 47 and line above)

googleit
09-01-2006, 06:41 PM
its now saying erro on line 60 but there is nothing on line 60 here is what is on line 47

$insert = "INSERT INTO users (username, password)
VALUES (".$_POST['username']."', '".$_POST['pass'].")";
$add_member = mysql_query('$insert');

musher
09-01-2006, 06:49 PM
its now saying erro on line 60 but there is nothing on line 60 here is what is on line 47

$insert = "INSERT INTO users (username, password)
VALUES (".$_POST['username']."', '".$_POST['pass'].")";
$add_member = mysql_query('$insert');
Try this, looks like your missing a couple of '

"INSERT INTO users (username, password) VALUES ('".$_POST['username']."', '".$_POST['pass']."'";

googleit
09-01-2006, 06:55 PM
nope that doesnt work :( any other ideas?

musher
09-01-2006, 07:24 PM
try previous post and this

$add_member = mysql_query($insert);

googleit
09-01-2006, 07:42 PM
thanks that got it :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum