Page 1 of 2
Another Parse Error
Posted: Sat Jul 24, 2004 7:01 pm
by robjime
I'm probably missing something simple...Theres a parse error on one of these 3 lines.
Code: Select all
<? php $Subject = "Your Sonicage Blog Account";
$Message = "Welcome to Sonicage Blog! Heres your information.<br> Name: $name <br> Username: $username <br> Password: $password <br><br> Your blog is viewable at http://www.sonicage.com/$username. To visit your control panel login at sonicage.com/blog/login.php. <br> Thank You";
$headers = "From: Blog Admin <webmaster@sonicage.com>\r\n";
?>
Posted: Sat Jul 24, 2004 7:28 pm
by brandan
are there any escape characters not being handled in the variables?
Posted: Sat Jul 24, 2004 8:02 pm
by robjime
im not sure what that means
Posted: Sat Jul 24, 2004 8:08 pm
by brandan
well, for instance, do the variables (such as $name) contain any characters that might cause the script to stop such as quotation marks or back slashes?
Posted: Sat Jul 24, 2004 8:26 pm
by robjime
nope
Posted: Sat Jul 24, 2004 9:28 pm
by John Cartwright
post the exact error plz
Posted: Sun Jul 25, 2004 3:56 am
by ol4pr0
Code: Select all
#as Phenom said state the error please, i cant see nothing at this moment that might cause an error..
#however this might look a bit better.
$Subject = "Your Sonicage Blog Account";
$Message = "Welcome to Sonicage Blog! Heres your information.<br> Name: '".$name."' <br> Username: '".$username."' <br> Password: '".$password."' <br><br> Your blog is viewable at http://www.sonicage.com/'".$username."'. To visit your control panel login at sonicage.com/blog/login.php. <br> Thank You";
$headers = "From: Blog Admin <webmaster@sonicage.com>\r\n";
Posted: Sun Jul 25, 2004 4:15 am
by lolpix
This bit of code looks okay...
Code: Select all
<?php
$Subject = "Your Sonicage Blog Account";
$Message = "Welcome to Sonicage Blog! Here is your information:
<br />
Name: $name
<br />
Username: $username
<br />
Password: $password
<br />
<br />
Your blog is viewable at http://www.sonicage.com/$username. To visit your control panel login at sonicage.com/blog/login.php.
<br />
Thank You";
$headers = "From: Blog Admin <webmaster@sonicage.com>\r\n";
?>
(I have re-written it an atypical PHP format, which would be one that other people can reasonably be expected to read

)
Posted: Sun Jul 25, 2004 4:17 am
by lolpix
Maybe this is causing problems?
Perhaps it is trying to concatenate $username with a variable (because of the period) that never comes?
Posted: Sun Jul 25, 2004 7:34 am
by robjime
Parse error: parse error in /home/robjime/public_html/blog/functions.php on line 39
Code: Select all
<?php
require_once ('functions.php');
$valid = TRUE;
$name=$_POST['name'];
$email=$_POST['email'];
$username=$_POST['username'];
$password=$_POST['password'];
$password2=$_POST['password2'];
if (isset ($_POST['submit'])) {
foreach($_POST as $key=>$value) {
$$key = $value;
}
$em = checkEmail($email);
$valid = $valid && $em;
$ps = checkPassword($password);
$valid = $valid && $ps;
$ps2 = $password == $password2;
$valid = $valid && $ps2;
$nusr = newuser($username);
$valid = $valid && nusr;
if ($valid) {
$user="*********";
$passwrd="********";
$database="********";
mysql_connect(localhost,$user,$passwrd);
@mysql_select_db($database) or die( "Unable to select database");
$query = "INSERT INTO users VALUES ('','$username','$pass','$name','$email')";
mysql_query($query);
mysql_close();
$To = $email;
$Subject = "Your Sonicage Blog Account";
$Message = "Welcome to Sonicage Blog! Heres your information.<br> Name: $name <br> Username: $username <br> Password: $password <br><br> Your blog is viewable at http://www.sonicage.com/$username! To visit your control panel login at sonicage.com/blog/login.php. <br> Thank You";
$headers = "From: Blog Admin <webmaster@sonicage.com>\r\n";
mail($To, $Subject, $Message, $headers);
echo "Your information has been emailed to you! Proceed to login <a href='login.php'>Click Here</a>";
exit;
}
} else {
$em = $ps = $ps2 = $nusr = TRUE;
echo '<form name="register" method="post" action="register.php">
<table width="100%" border="0">
<tr>
<td>Name:</td>
<td><input name="name" type="text" id="name"></td>
</tr>
<tr>
<td'; if(!$em){echo 'class="error"';} echo '>Email:</td>
<td><input name="email" type="text" id="email"></td>
</tr>
<tr>
<td'; if(!nusr) {echo 'class="error"';} echo '>Username:</td>
<td><input name="username" type="text" id="username"><br>'; if(!nusr) {echo '<font color="#FF0000" size="2">Username already taken!</font>';} echo '</td>
</tr>
<tr>
<td'; if(!($ps && $ps2)) {echo 'class="error"';} echo'>Password:</td>
<td><input name="password" type="password" id="password"></td>
</tr>
<tr>
<td>Password must be at least 6 chars. in lenth.</td>
</tr>
<tr>
<td'; if(!($ps && $ps2)) {echo 'class="error"';} echo '>Re-type Password:</td>
<td><input type="password" name="password2"></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" value="Register">
<input type="reset" name="Submit2" value="Reset"></td>
</tr>
</table>
</form>';
}
?>
functions.php
Code: Select all
<?php
function checkPassword($password) {
$length = strlen ($password);
if ($length < 6) {
return FALSE;
}
}
function checkEmail($email) {
$pattern = "/^[A-z0-9\._-]+"
. "@"
. "[A-z0-9][A-z0-9-]*"
. "(\.[A-z0-9_-]+)*"
. "\.([A-z]{2,6})$/";
return preg_match ($pattern, $email);
}
function newuser($username) {
$user="robjime";
$passwrd="888888888";
$database="888888888_";
mysql_connect(localhost,$user,$passwrd);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM users";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num) {
$dbuser=mysql_result($result,$i,"user");
$i++;
}
if(preg_match($username, $dbuser) {
return FALSE;
}
}
?>
feyd | removed user/password
Posted: Sun Jul 25, 2004 10:56 am
by zenabi
You are missing a closing bracket at the end of your code. It should be this:
Code: Select all
if(preg_match($username, $dbuser)) { /* note the extra ) */
return FALSE;
}
Posted: Sun Jul 25, 2004 11:52 am
by feyd
also, I noticed that $nusr is used without the dollar sign twice in the echo junk..
Posted: Sun Jul 25, 2004 6:46 pm
by brandan
i have all your passwords!!
Posted: Sun Jul 25, 2004 6:59 pm
by d3ad1ysp0rk
Don't be like that brandan.
Robjime, please change all your passwords (ftp, db, etc).
some members may use them for malicious things.
And remember, never post direct code without double checking that passwords are edited out (****, etc..).
Posted: Sun Jul 25, 2004 9:11 pm
by brandan
be like what? i said what you said in only 5 words. that's optimization at its best!