• Welcome to Valhalla Legends Archive.
 

Parse Error in code on line 38

Started by ChroniX, February 19, 2008, 04:27 PM

Previous topic - Next topic

ChroniX

I get a parse error on line 38 when I run this script, yet it runs fine on my other pages. Also, the page will work properly if the php code is taken out, so I'm not really sure what to make of this error.


<?php
mysql_connect
("localhost","brian","password") or die (mysql_error());
mysql_select_db("user_login") or die (mysql_error());

if(isset(
$_COOKIE['ID_my_site']))

{
$username $_COOKIE['ID_my_site'];
$pass $_COOKIE['Key_my_site'];
$check mysql_query("SELECT * FROM users WHERE username = '$username'")or die (mysql_error());
while(
$info mysql_fetch_array$check ))
{
if (
$pass != $info['password'])
{
}
else
{

<
b>Enter Project Information - Return <a href="home.php">home</a>.</b>

<
br><br>

<
pre>
<
form action="insert_project_info.php" method="post">
Project Number:      <input type="text" name="projectnumber" /><br>
Project Name:        <input type="text" name="projectname" /><br>
Client Name:         <input type="text" name="clientname" /><br>
Client Address:      <input type="text" name="clientaddress" /><br>
Client Office Phone: <input type="text" name="clientofficephone" /><br>
Client Fax:          <input type="text" name="clientfax" /><br>
Client Cell:         <input type="text" name="clientcell" /><br>
Client Email:        <input type="text" name="clientemail" /><br>
<
input type="submit" value="Submit" /> <input type="reset" value="Clear" />
</
form>
</
pre>

}
?>


Barabajagal

You did it wrong. (You can't just put HTML into PHP like that!)

ChroniX

Well I'm not sure exactly what I've done wrong, since after all, the script works fine on all of my other pages. Any suggestions as to what changes should be made?

ChroniX

Well it's done here on my login page, same concept. So I'm not sure what I did different. Could you point me in the right direction as far as what changes need to be made to my source?


<?php
mysql_connect
("localhost","brian","password") or die (mysql_error());
mysql_select_db("user_login") or die (mysql_error());

if(isset(
$_COOKIE['ID_my_site']))

{
$username $_COOKIE['ID_my_site'];
$pass $_COOKIE['Key_my_site'];
$check mysql_query("SELECT * FROM users WHERE username = '$username'")or die (mysql_error());
while(
$info mysql_fetch_array$check ))
{
if (
$pass != $info['password'])
{
}
else
{
header("Location: home.php");

}
}
}

if (isset(
$_POST['submit'])) { if(!$_POST['username'] | !$_POST['pass']) { die ('You did not fill in a required field.'); }

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

$check2 mysql_num_rows($check); if ($check2 == 0) { die ('That user does not exist in the database. <a href="register.php">Click here to register</a>'); }
while(
$info mysql_fetch_array$check ))
{
$_POST['pass'] = stripslashes($_POST['pass']);
$info['password'] = stripslashes($info['password']);
$_POST['pass'] = md5($_POST['pass']);

if (
$_POST['pass'] != $info['password']) { die ('Incorrect password, please try again.'); }

else
{

$_POST['username'] = stripslashes($_POST['username']);
$hour time() + 3600;
setcookie(ID_my_site$_POST['username'], $hour);
setcookie(Key_my_site$_POST['pass'], $hour);

header("Location: home.php");
}
}
}
else
{

?>

<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
<table border="0">
<tr><td colspan=2><h1>Login</h1></td></tr>
<tr><td>Username:</td><td>
<input type="text" name="username" maxlength="40">
</td></tr>
<tr><td>Password:</td><td>
<input type="password" name="pass" maxlength="50">
</td></tr>
<tr><td colspan="2" align="right">
<input type="submit" name="submit" value="Login">
</td></tr>
</table>
</form>
<?php
}
?>


brew

Quote from: Andy on February 19, 2008, 04:39 PM
You did it wrong. (You can't just put HTML into PHP like that!)
Sure he could, it just needs to be outside of the <? ?> braces.
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

Barabajagal

<? and ?> denote php starting and ending. What you just said was retarded brew. GTFO.

ChroniX, notice how on the code you just pasted, you end the PHP section before the HTML starts?

ChroniX

First of all, brew, <? and?> isn't the proper way to begin and end a php script, <?php //code ?> is.  :)

Andy, thank you for pointing that out.

brew

Quote from: Andy on February 19, 2008, 05:16 PM
<? and ?> denote php starting and ending. What you just said was retarded brew. GTFO.
No, <? and ?> are the brackets in which the code must be. Anything else not in those would be sent to the client as-is. anotherwords, you could put raw html, as long as it is around the brackets. thanks.
@Chronix: Isn't it funny how <? works just as well? I wonder why. And do you honestly think you need to add //code.....? That's what they call a comment.
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

ChroniX

brew, I said using <?php to begin a script is the proper way to use it, although I'm not in denial against your method of beginning with <?, it works as well. So I never said you were wrong, I was simply pointing out the proper way to use the tags. As for the //code, that was to refer to whatever is being put inside the script, which in that case, nothing at all. It was simply an example. GFY.

Barabajagal

It only works if you configure php.ini to allow short opening tags. Give up, brew.

brew

Quote from: Andy on February 19, 2008, 06:05 PM
It only works if you configure php.ini to allow short opening tags. Give up, brew.

In that case, every web server i've put a script on that uses <? must have it configured so.
Give up what? I don't see what there is to give up on? Unless this is your idea of a 'game'... It's funny how defensive you get when someone says something contrary to your own word.

Chronix: GFY to you too!.
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

Barabajagal


ChroniX

He's trolling, we must not feed him! :)

Dale

lol.

I have to say this was probably the worst thread I've ever seen go from a question to a retarded argument.