View Full Version : PHP thing
purple_ivy 06-15-2004, 11:34 PM I downloaded Fanbase 2 from CodeGrrl.com.
I have posted about this in their forum about a week ago, but no one answered, so I'm HOPING you guys might be familiar with the program and may be able to help me :)
This error keep coming up when I try to access my admin.php page:
Parse error: parse error, unexpected '!', expecting ',' or ';' in /home/.naomi/pbsam/tallulah.prettybloomers.com/login.php on line 16
this is line 16 of my login.php page:
<? if (substr($PHP_SELF,-9) == "login.php") { echo "<p>Never link directly to this file, always link to the protected file!</p>"; } else { echo "<INPUT TYPE=submit VALUE="/Login!/">"; }?>
I know it's a long shot, but I'm really hoping SOMEONE has some idea of how to fix this!
thanks :)
Demented 06-15-2004, 11:56 PM Well, your error says expecting ; or , so instead of:
<? if (substr($PHP_SELF,-9) == "login.php") { echo "<p>Never link directly to this file, always link to the protected file!</p>"; } else { echo "<INPUT TYPE=submit VALUE="/Login!/">"; }?>
Try something like:
<? if (substr($PHP_SELF,-9) == "login.php") { echo "<p>Never link directly to this file, always link to the protected file.</p>"; } else { echo "<INPUT TYPE=submit VALUE="/Login!/">"; }?>
purple_ivy 06-16-2004, 12:41 AM Well, your error says expecting ; or , so instead of:
Try something like:
Nope, didn't work. So I've changed it back.
Here is the entire login.php code if this helps anyone:
<html>
<head>
<title>PHPFanBase______</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body style="background-color:#9999CC;">
<div align="center"><img src="logo.jpg" border="0"></div>
<div align="center">
<FORM METHOD=post ACTION="<? echo $PHP_SELF ?>?action=login">
<B>Login name:</B><BR>
<INPUT TYPE=text SIZE=30 NAME=loginname><BR>
<B>Password:</B><BR>
<INPUT TYPE=password SIZE=30 NAME=password><BR>
<? if (substr($PHP_SELF,-9) == "login.php") { echo "<p>Never link directly to this file, always link to the protected file!</p>"; } else { echo "<INPUT TYPE=submit VALUE="/Login!/">"; }?>
</FORM>
</div>
<div align="center" style="border-top: 1px solid #404040; padding-top:5px;">
© Copyright <a href="http://nothing-less.net" target="_blank">Sasha</a>, 2003. All Rights Reserved.<br>PHPFanBase v2.0</div>
</BODY>
</HTML>
tucker 06-16-2004, 01:25 AM <? if (substr($PHP_SELF,-9) == "login.php") { echo "<p>Never link directly to this file, always link to the protected file!</p>"; } else { echo "<INPUT TYPE=submit VALUE="/Login!/">"; }?>
in php, ! is a logical operator, so you cant use it. Take both of them out.
you can probably get it in some way.
purple_ivy 06-16-2004, 04:46 AM <? if (substr($PHP_SELF,-9) == "login.php") { echo "<p>Never link directly to this file, always link to the protected file!</p>"; } else { echo "<INPUT TYPE=submit VALUE="/Login!/">"; }?>
in php, ! is a logical operator, so you cant use it. Take both of them out.
you can probably get it in some way.
Ok, well that worked, but where the login button should be I have:
Warning: Division by zero in /home/.naomi/pbsam/tallulah.prettybloomers.com/login.php on line 16
Warning: Division by zero in /home/.naomi/pbsam/tallulah.prettybloomers.com/login.php on line 16
What on earth is that?
jtchange 06-16-2004, 02:22 PM ok, well the first thing i noticed is that you aren't escaping your quotes correctly, it's not a forward slash(/) it's a backward slash(\) so it should be:
<? if (substr($PHP_SELF,-9) == "login.php") { echo "<p>Never link directly to this file, always link to the protected file!</p>"; } else { echo "<INPUT TYPE=submit VALUE=\"Login!\">"; }?>
and by the way, the reason you were getting a divide by 0 error is because you can't divide an ! by an " :lol:
Fluffy2000 06-16-2004, 10:02 PM I noticed that your site is hosted on geocities...If you're trying to host it there, it won't work, they don't support PHP.
tucker 06-16-2004, 10:31 PM well,its obviously not free because they got an error message for their php code, meaning that theyre host supports it.
and yeah, / is a math operator in php. so if you want / displayed in your button, im not sure how.
purple_ivy 06-16-2004, 11:16 PM ok, well the first thing i noticed is that you aren't escaping your quotes correctly, it's not a forward slash(/) it's a backward slash(\) so it should be:
<? if (substr($PHP_SELF,-9) == "login.php") { echo "<p>Never link directly to this file, always link to the protected file!</p>"; } else { echo "<INPUT TYPE=submit VALUE=\"Login!\">"; }?>
and by the way, the reason you were getting a divide by 0 error is because you can't divide an ! by an " :lol:
I changed the slashes, but I got parse errors & another warning, just on a blank white screen.
I have no idea what deviding is. Infact I pretty much know zero about PHP. I'm starting to think the CodeGrrl people who wrote this scripts are on something highly illegal...
but thank you anyway for your help :)
purple_ivy 06-16-2004, 11:18 PM I noticed that your site is hosted on geocities...If you're trying to host it there, it won't work, they don't support PHP.
I'm hosted by Dreamhost, actually :)
jtchange 06-17-2004, 11:52 AM if there isn't any crucial information on the page(like database passwords and such) could we see the code? and do you want those slashes IN the button? or not?
purple_ivy 06-17-2004, 10:45 PM I don't want the slashes in the button. Oh and by the way, I didn't write the code myself, I downloaded it.
That's the code for my admin.php page, which is the one I'm trying to access, but you have to log in via the login.php page. the code for that page is posted in one of my above replies.
<?
// include configuration and password protection
include("config.php");
include("protection.php");
$today = date("F j, Y");
?>
<html>
<head>
<title>PHPFanBase______</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body style="background-color:#9999CC;">
<div align="center"><img src="logo.jpg" border="0"></div>
<?
if (!$action || $action== "login"){
// get total member count
$querycount="SELECT id FROM $table";
$resultcount=mysql_query($querycount);
$numcount=mysql_numrows($resultcount);
// get total pending member count
$querycount2="SELECT apr FROM $table WHERE apr!='y'";
$resultcount2=mysql_query($querycount2);
$numcount2=mysql_numrows($resultcount2);
?><h2>Approve Members</h2>
<p>You have a total of <strong><?=$numcount?></strong> members for <?=$sitename?>, of which <strong><?=$numcount2?></strong> are unapproved.</p>
<?
// select all unapproved members
$result = mysql_query ("SELECT * FROM $table WHERE apr!='y'");
if ($row = mysql_fetch_array($result)) {
do {
// display all unapproved members
?>
<div align="center"><form action="admin.php" method="post">
<input type="hidden" name="action" value="approve">
<table border="0" cellspacing="0" cellpadding="2">
<tr><td>ID: <input type="text" name="id" size="10" class="form" value="<?=$row["id"]?>"></td><td>Hide Email: <input type="text" name="hideemail" size="20" class="form" value="<?=$row["hideemail"]?>">
("n" means Show Email, "h" means Hide Email)</td></tr>
<tr><td>Name: </td><td><input type="text" name="name" size="80" class="form" value="<?=$row["name"]?>"></td></tr>
<tr><td>Email: </td><td><input type="text" name="email" size="80" class="form" value="<?=$row["email"]?>"></td></tr>
<tr><td>URL: </td><td><input type="text" name="url" size="80" class="form" value="<?=$row["url"]?>"> (<a href="<?=$row["url"]?>" target="_blank">check site</a>)</td></tr>
<tr><td>Country: </td><td><input type="text" name="country" size="80" class="form" value="<?=$row["country"]?>"></td></tr>
<? if ($enablefave == 'Y'){ ?>
<tr><td><?=$whatfave?>: </td><td><input type="text" name="fave" size="80" class="form" value="<?=$row["fave"]?>"></td></tr>
<? } ?>
<tr><td>Comments: </td><td><textarea rows="3" name="comments" cols="40" class="form"><?=$row["comments"]?></textarea></td></tr>
<tr><td>Action: </td><td><select name="what" class="button">
<option value="up" SELECTED>Update</option>
<option value="del">Delete</option></select></td></tr>
<tr><td colspan="2"><input type="Submit" class="button"></td></tr></table>
</form></div>
<?
} while($row = mysql_fetch_array($result));
// if there are no unapproved members, print just p tags
} else {print "<p></p>";}
} elseif ($action == "approve"){
// if the Approve button was clicked, do the following
if ($what == "up"){
//if you selected Update under Action, do the following
if ($membernotify == "Y"){
// if you have member emails turned on, email them the following upon Approval
$recipient = "$_POST[email]";
$subject = "$sitename: You have been added!";
$mailheaders = "From: $adminemail\n";
$mailheaders .= "Reply-To: $adminemail\n\n";
if ($enablefave == 'Y'){
mail($recipient, $subject, "Hi $_POST[name], you have been added to the Members List at $sitename ($siteurl) with the following information: \n\n Name: $_POST[name] \n Email: $_POST[email] \n URL: $_POST[url] \n Country: $_POST[country] \n $whatfave: $_POST[fave] \n\n Thank you for joining, and don't forget to put a link back up to to $siteurl if you own a website and haven't done so already! \n\n $adminname \n $admincollective", "$mailheaders");
} else { mail($recipient, $subject, "Hi $_POST[name], you have been added to the Members List at $sitename ($siteurl) with the following information: \n\n Name: $_POST[name] \n Email: $_POST[email] \n URL: $_POST[url] \n Country: $_POST[country] \n\n Thank you for joining, and don't forget to put a link back up to to $siteurl if you own a website and haven't done so already! \n\n $adminname \n $admincollective", "$mailheaders"); } }
// update the table to make the member approved
if ($enablefave == 'Y'){
$query = "UPDATE $table SET name='$name', email='$email', url='$url', country='$country', comments='$comments', hideemail='$hideemail', apr='y', fave='$fave' WHERE id='$id'";
} else {
$query = "UPDATE $table SET name='$name', email='$email', url='$url', country='$country', comments='$comments', hideemail='$hideemail', apr='y' WHERE id='$id'";
}
mysql_query($query);
} elseif ($what == "del"){
// delete the member
$query = "DELETE from $table WHERE id='$id'";
mysql_query($query);
}
//change last updated date
$query = "UPDATE $table_u SET date='$today' WHERE id='1'";
mysql_query($query);
// again, select all unapproved
$result = mysql_query ("SELECT * FROM $table WHERE apr!='y'");
if ($row = mysql_fetch_array($result)) {
//display all unapproved
do { ?>
<div align="center"><form action="admin.php" method="post">
<input type="hidden" name="action" value="approve">
<table border="0" cellspacing="0" cellpadding="2">
<tr><td>ID: <input type="text" name="id" size="20" class="form" value="<?=$row["id"]?>"></td><td>Hide Email: <input type="text" name="hideemail" size="20" class="form" value="<?=$row["hideemail"]?>"><br>
("n" means Show Email, "h" means Hide Email)</td></tr>
<tr><td>Name: </td><td><input type="text" name="name" size="80" class="form" value="<?=$row["name"]?>"></td></tr>
<tr><td>Email: </td><td><input type="text" name="email" size="80" class="form" value="<?=$row["email"]?>"></td></tr>
<tr><td>URL: </td><td><input type="text" name="url" size="80" class="form" value="<?=$row["url"]?>"> (<a href="<?=$row["url"]?>" target="_blank">check site</a>)</td></tr>
<tr><td>Country: </td><td><input type="text" name="country" size="80" class="form" value="<?=$row["country"]?>"></td></tr>
<? if ($enablefave == 'Y'){ ?>
<tr><td><?=$whatfave?>: </td><td><input type="text" name="fave" size="80" class="form" value="<?=$row["fave"]?>"></td></tr>
<? } ?>
<tr><td>Comments: </td><td><textarea rows="3" name="comments" cols="40" class="form"><?=$row["comments"]?></textarea></td></tr>
<tr><td>Action: </td><td><select name="what" class="button">
<option value="up" SELECTED>Update</option>
<option value="del">Delete</option></select></td></tr>
<tr><td colspan="2"><input type="Submit" class="button"></td></tr></table>
</form></div>
<?
} while($row = mysql_fetch_array($result));
} else {print "<p>No more unapproved members! Click <a href=\"admin.php\">here</a> to go back to the main Admin Panel.</p>";}
} elseif ($action == "edit"){
// the Edit members screen
?>
that's not all the code, I'll post the rest in another reply because it's too long
purple_ivy 06-17-2004, 10:47 PM ok here's the rest:
<h2>Edit Member Information</h2>
<div align="center"><form action="admin.php" method="post">
<input type="hidden" name="action" value="select">
<table border="0" cellspacing="0" cellpadding="2">
<tr><td>ID: </td><td><input type="text" name="id" size="80" class="form"></td></tr>
<tr><td>Name: </td><td><input type="text" name="name" size="80" class="form"></td></tr>
<tr><td>Email: </td><td><input type="text" name="email" size="80" class="form"></td></tr>
<tr><td>URL: </td><td><input type="text" name="url" size="80" class="form"></td></tr>
<tr><td>Country: </td><td><input type="text" name="country" size="80" class="form"></td></tr>
<? if ($enablefave == 'Y'){ ?>
<tr><td><?=$whatfave?>: </td><td><input type="text" name="fave" size="80" class="form"></td></tr>
<? } ?>
<tr><td colspan="2"><input type="Submit" class="button"></td></tr></table>
</form></div>
<? } elseif ($action == "select"){
//the search results from the Edit Member screen
?>
<h2>Edit Member Information</h2> <?
if ($id == "")
{$id = '%';}
if ($name == "")
{$name = '%';}
if ($email == "")
{$email = '%';}
if ($url == "")
{$url = '%';}
if ($country == "")
{$country = '%';}
if ($enablefave == 'Y'){
if ($fave == "")
{$fave = '%';}
// select the right records
$result = mysql_query ("SELECT * FROM $table WHERE id LIKE '$id' AND name LIKE '%$name%' AND email LIKE '%$email%' AND url LIKE '%$url%' AND country LIKE '$country%' AND fave LIKE '%$fave%'");
} else {
$result = mysql_query ("SELECT * FROM $table WHERE id LIKE '$id' AND name LIKE '%$name%' AND email LIKE '%$email%' AND url LIKE '%$url%' AND country LIKE '$country%'");
}
if ($row = mysql_fetch_array($result)) {
do {
// display the search results
?>
<div align="center"><form action="admin.php" method="post">
<input type="hidden" name="action" value="update">
<table border="0" cellspacing="0" cellpadding="2">
<tr><td>ID: <input type="text" name="id" size="20" class="form" value="<?=$row["id"]?>"></td><td>Hide Email: <input type="text" name="hideemail" size="20" class="form" value="<?=$row["hideemail"]?>"><br>
("n" means Show Email, "h" means Hide Email)</td></tr>
<tr><td>Name: </td><td><input type="text" name="name" size="80" class="form" value="<?=$row["name"]?>"></td></tr>
<tr><td>Email: </td><td><input type="text" name="email" size="80" class="form" value="<?=$row["email"]?>"></td></tr>
<tr><td>URL: </td><td><input type="text" name="url" size="80" class="form" value="<?=$row["url"]?>"> (<a href="<?=$row["url"]?>" target="_blank">check site</a>)</td></tr>
<tr><td>Country: </td><td><input type="text" name="country" size="80" class="form" value="<?=$row["country"]?>"></td></tr>
<? if ($enablefave == 'Y'){ ?>
<tr><td><?=$whatfave?>: </td><td><input type="text" name="fave" size="80" class="form" value="<?=$row["fave"]?>"></td></tr>
<? } ?>
<tr><td>Comments: </td><td><textarea rows="3" name="comments" cols="40" class="form"><?=$row["comments"]?></textarea></td></tr>
<tr><td>Action: </td><td><select name="what" class="button">
<option value="up" SELECTED>Update</option>
<option value="del">Delete</option></select></td></tr>
<tr><td colspan="2"><input type="Submit" class="button"></td></tr></table>
</form></div>
<?} while($row = mysql_fetch_array($result));
//if nothing was found, display the following
} else {print "<p>Sorry, no records were found! Please press the back button on your browser to try again. <br>
Tip: you don't have to fill in all the fields in the Edit form. Filling in just one or two will return all members with that information, it works like a search form. :)</p>";}
} elseif ($action == "update"){
if ($what == "up"){
//Update a member through the Edit Member screen
if ($enablefave == 'Y'){
$query = "UPDATE $table SET name='$name', email='$email', url='$url', country='$country', comments='$comments', hideemail='$hideemail', apr='y', fave='$fave' WHERE id='$id'";
mysql_query($query);
} else {
$query = "UPDATE $table SET name='$name', email='$email', url='$url', country='$country', comments='$comments', hideemail='$hideemail', apr='y' WHERE id='$id'";
mysql_query($query);
}
// Delete a member through the Edit Member screen
} elseif ($what == "del"){
$query = "DELETE from $table WHERE id='$id'";
mysql_query($query);
}
//change the last updated date
$query = "UPDATE $table_u SET date='$today' WHERE id='1'";
mysql_query($query);
echo "<p>This member was updated succesfully! Click <a href=\"admin.php\">here</a> to return to the Admin Panel.</p>"; ?>
<? } elseif ($action == "emailall"){
//email all members
?>
<p>Using this function, you can email all the members of your fanlisting through a script. You won't have to start up your email program, it can all be done online.<br>
Please note that once you click the send button, you cannot undo or stop the process. Pressing the Send button twice will result in everyone receiving two emails, so please use this function responsibly!</p>
<p>To see what your email will look like once it's sent, select "Yourself Only" in the "Send It To" drop down box. This will send the below email to yourself, to the address specified in the config.php file. If you select "All Members", the email will be sent to everyone on your member list.</p>
<p>Please feel free to change the below email as needed.</p>
<p><strong>Please note that if your member list is longer than 100 members, the Sent page might take a while to load! This is perfectly normal, please don't refresh or close the window...wait until the page is fully loaded before doing anything else!</strong></p>
<div align="center"><form action="admin.php" method="post">
<input type="hidden" name="action" value="sendall">
<table border="0" cellspacing="0" cellpadding="2">
<tr><td>Subject: </td><td><input type="text" name="subject" size="80" class="form" value="The <?=$sitename?> Fanlisting Has Moved!"></td></tr>
<tr><td>Body: </td><td><textarea rows="6" name="body" cols="70" class="form">Hi,
You're receiving this email because you're a member of <?=$sitename?>. I wanted to let you know that I moved the fanlisting over a new address.
The new url is <?=$siteurl?>.
I would really appreciate it if you could update your links and bookmarks when you have a free moment. :) Thanks so much in advance!
<?=$adminname?>__
<?=$admincollective?></textarea></td></tr>
<tr><td>Send it to: </td><td><select name="what" class="button">
<option value="you" SELECTED>Yourself Only</option>
<option value="all">All Members</option></select></td></tr>
<tr><td colspan="2"><input type="Submit" class="button" value="Send!"></td></tr></table>
</form></div>
<? } elseif ($action == "sendall"){
//send the email just to you
if ($what == "you"){
$recipient = "$adminemail";
$subject = "$_POST[subject]";
$mailheaders = "From: $adminemail\n";
$mailheaders .= "Reply-To: $adminemail\n\n";
mail($recipient, $subject, "$_POST[body]", "$mailheaders");
echo "<p>The email has been sent to yourself. Check your email to make sure this is how you want it to look, and press the back button to return to the previous screen.</p>";
//send it to everyone
} elseif ($what == "all"){
$query="SELECT * FROM $table";
$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
$email=mysql_result($result,$i,"email");
$name=mysql_result($result,$i,"name");
$url=mysql_result($result,$i,"url");
$msg = stripslashes($_POST[body]);
$recipient = "$email";
$subject = "$_POST[subject]";
$mailheaders = "From: $adminemail\n";
$mailheaders .= "Reply-To: $adminemail\n\n";
mail($recipient, $subject, $msg, $mailheaders);
echo "<p>This email has been sent to:<br>";
echo "$name :: $email<br>";
++$i; }
} ?>
<? } elseif ($what == "invalid"){ ?>
<p><B>Invalid login name or password!</B><BR>Please press the back button on your browser to try again.</p>
<? }
//the footer navigation ?>
<div align="center"><a href="admin.php">Approve Members</a> :: <a href="admin.php?action=edit">Edit Members</a> :: <a href="admin.php?action=emailall">Email Members</a> :: <a href="admin.php?action=logout">Logout</a></div>
<div align="center" style="border-top: 1px solid #404040; padding-top:5px; margin-top:5px;">
© Copyright <a href="http://nothing-less.net" target="_blank">Sasha</a>, 2003. All Rights Reserved.<br>PHPFanBase v2.0</div>
<? echo "</body></html>";
?>
purple_ivy 06-18-2004, 09:27 AM I just want to thank everyone for their help :)
But I decided to download the CodeGrrl PHPFanbace v2.0 again.
It's working now.
But thank you anyway!! :)
|