PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Wldrumstcs
Forum Commoner
Posts: 98 Joined: Wed Nov 26, 2003 8:41 pm
Post
by Wldrumstcs » Thu Jan 27, 2005 7:00 pm
I have posted this several times, but it hasn't been solved yet. Basically, on line 111 (the line saying ' $main .= "</select> '), there is a parse error saying that there's an unexpected T_Variable. I posted the entire code so you can help me locate the error. Where is it?
Code: Select all
<?
mysql_connect("localhost","$username","$password") or die ("Unable to connect to MySQL server.");
$db = mysql_select_db("$database") or die ("Unable to select requested database.");
$admin = 0;
if($_COOKIEїid] != '' AND $_COOKIEїusername] != '' and $_COOKIEїpassword] !='') {
$result = mysql_query("SELECT username FROM teachers WHERE username='$_COOKIEїusername]' AND password='$_COOKIEїpassword]' AND id='$_COOKIEїid]'");
if(mysql_num_rows($result) > 0)
$admin = 1;
}
if($admin == 1) {
IF($_GETїa] == "delete") {
mysql_connect("localhost","$username","$password") or die ("Unable to connect to MySQL server.");
$db = mysql_select_db("$database") or die ("Unable to select requested database.");
$sql = "DELETE FROM teachers WHERE username='$_POSTїfilter_teachers]'";
$result = mysql_query($sql);
$main = "<font size='4'><b>$_POSTїfilter_teachers] has been deleted from the database.</b></font><br>You are being redirected...";
echo "<head><meta http-equiv='refresh' content='3;URL=admin.php'></head>";
}ELSEIF($_GETїa] == "verify") {
$main = " <form method='POST' action='delete.php?a=delete'>
<table border='0' width='100%' cellspacing='0' cellpadding='0' id='table10'>
<tr>
<td align='right' width='100%' colspan='2'>
<p align='center'><b><font size='2'>*NOTE*: Don't abuse this power...</font></b></td>
</tr>
<tr>
<td height='10'>
</td>
</tr>
<tr>
<td align='right' width='50%'>
<p align='right'><b>Your Name:</b></td>
<td align='left' width='50%'>$_COOKIEїusername]</td>
</tr>
<tr>
<td align='right' width='50%'>
<p align='right'><b>Teacher that will be deleted:</b></td>
<td align='left' width='50%'>$_POSTїfilter_teachers]</td>
</tr>
</table>
<p>
<a href='javascript:history.go(-1);'>
If you want to change something, click here.</a></p>
<p>
<input type='hidden' name='filter_teachers' value="$_POSTїfilter_teachers]">
<input type='submit' value='OK, Delete $_POSTїfilter_teachers]' name='submit1' tabindex='3' style='font-weight: bold; border-style: dashed; border-width: 1px; background-color: #999999'></p>
</form>
";
}
ELSEIF($_GETїa] != "logout" OR $_GETїa] != "verify" OR $_GETїa] != "post"){
mysql_connect("localhost","$username","$password") or die ("Unable to connect to MySQL server.");
$db = mysql_select_db("$database") or die ("Unable to select requested database.");
$query="SELECT * FROM teachers ORDER BY id ASC";
$result=mysql_query($query);
$main = "<form method='POST' action='delete.php?a=verify'>
<table border='0' width='100%' cellspacing='0' cellpadding='0' id='table10'>
<tr>
<td align='center' width='100%' colspan='2'>
<b><font size='2'>*NOTE*: Don't abuse this power...</font></b></td>
</tr>
<tr>
<td height='10'>
</td>
</tr>
<tr>
<td align='right' width='50%' valign='top'>
<p align='right'><b>Your Name:</b></td>
<td align='left' width='50%'>$_COOKIEїusername]<br>
<font size='2'>(To login under a different username, </font>
<a href='http://www.***.com/login.php?a=logout'>
<font size='2'>click here.)</font></a></td>
</tr>
<tr>
<td align='right' width='50%'><b>Teacher that will be deleted:</b></td>
<td width='50%' align='left'>
<select name='filter_teachers'>
<option value='showall'>Choose a Teacher</option>
<option>----------------------</option>";
while ($teacher = mysql_fetch_array($result)){
$main .= "<option value='$teacherїusername]'>$teacherїusername]</option>\n";
$main .= "</select>
</td>
</tr>
<tr>
<td align='right' width='50%'> </td>
<td align='left' width='50%'> </td>
</tr>
</table>
<p>
<input type='submit' value='Proceed' name='submit' tabindex='3' style='font-weight: bold; border-style: dashed; border-width: 1px; background-color: #999999'></p>
</form>";
}}
?>
Last edited by
Wldrumstcs on Thu Jan 27, 2005 8:30 pm, edited 1 time in total.
wyred
Forum Commoner
Posts: 86 Joined: Mon Dec 20, 2004 1:59 am
Location: Singapore
Post
by wyred » Thu Jan 27, 2005 7:36 pm
You didn't close the opening curly bracket on line 11.
if($admin == 1) {
Wldrumstcs
Forum Commoner
Posts: 98 Joined: Wed Nov 26, 2003 8:41 pm
Post
by Wldrumstcs » Thu Jan 27, 2005 7:44 pm
Actually, I did, but it's in the other part of the script. This is the entire portion above the <html> tags.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Jan 27, 2005 7:53 pm
out of curiosity, what editor are you using?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Jan 27, 2005 7:55 pm
comment out parts, and see if the location changes.. Rewrite lines, completely if needed.
Wldrumstcs
Forum Commoner
Posts: 98 Joined: Wed Nov 26, 2003 8:41 pm
Post
by Wldrumstcs » Thu Jan 27, 2005 8:01 pm
That's the damndest thing, I rewrote some lines, and it now works. However, I didn't change anything ??? Weird. Anyways, for some reason, there is a HUGE number of breaks before the *note:please dont abuse this power* line around line 100. Where's the error?
Wldrumstcs
Forum Commoner
Posts: 98 Joined: Wed Nov 26, 2003 8:41 pm
Post
by Wldrumstcs » Thu Jan 27, 2005 8:03 pm
Also, I don't see any <br> in the outputted HTML or anything that would create a break.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Jan 27, 2005 8:07 pm
it's possible you had some ~blank binary data in there or other things..
not sure how you'd do it other than copy and pasting something that the DDE may have screwed up, although the DDE is usually real good.
I'd suggest switching to a decent editor
Wldrumstcs
Forum Commoner
Posts: 98 Joined: Wed Nov 26, 2003 8:41 pm
Post
by Wldrumstcs » Thu Jan 27, 2005 8:11 pm
Which editor do you recommend?
Wldrumstcs
Forum Commoner
Posts: 98 Joined: Wed Nov 26, 2003 8:41 pm
Post
by Wldrumstcs » Thu Jan 27, 2005 8:14 pm
Oh, here's the new HTML that is outputted:
Code: Select all
<form method='POST' action='delete.php?a=verify'>
<table border='0' width='100%' cellspacing='0' cellpadding='0' id='table10'>
<tr>
<td align='center' width='100%' colspan='2'>
<b><font size='2'>*NOTE*: Don't abuse this power...</font></b></td>
</tr>
<tr>
<td height='10'>
</td>
</tr>
<tr>
<td align='right' width='50%' valign='top'>
<p align='right'><b>Your Name:</b></td>
<td align='left' width='50%'>Greg Gebhardt<br>
<font size='2'>(To login under a different username, </font>
<a href='http://www.***.com/login.php?a=logout'>
<font size='2'>click here.)</font></a></td>
</tr>
<tr>
<td align='right' width='50%'><b>Teacher that will be deleted:</b></td>
<td width='50%' align='left'>
<select name='filter_teachers'>
<option value='showall'>Choose a Teacher</option>
<option>----------------------</option><option value='Kari Cook'>Kari Cook</option>
<option value='Jenne Dehmlow'>Jenne Dehmlow</option>
<option value='Shirley Diaz'>Shirley Diaz</option>
<option value='Daryl Fitts'>Daryl Fitts</option>
<option value='Greg Gebhardt'>Greg Gebhardt</option>
<option value='Todd Kristensen'>Todd Kristensen</option>
<option value='Dan Korntheuer'>Dan Korntheuer</option>
<option value='James Lambatos'>James Lambatos</option>
<option value='Steve Linhardt'>Steve Linhardt</option>
<option value='Lindsay Moen'>Lindsay Moen</option>
<option value='Laura Morgan'>Laura Morgan</option>
<option value='Johnna Norbut'>Johnna Norbut</option>
<option value='Doug Rushing'>Doug Rushing</option>
<option value='Bill Schreier'>Bill Schreier</option>
<option value='Matt Stellwagen'>Matt Stellwagen</option>
<option value='Dennis Walker'>Dennis Walker</option>
<option value='Chuck Williams'>Chuck Williams</option>
<option value='Shana Willilams'>Shana Willilams</option>
</select>
</td>
</tr>
<tr>
<td align='right' width='50%'> </td>
<td align='left' width='50%'> </td>
</tr>
</table>
<p>
<input type='submit' value='Proceed' name='submit' tabindex='3' style='font-weight: bold; border-style: dashed; border-width: 1px; background-color: #999999'></p>
</form>
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Jan 27, 2005 8:18 pm
please edit your post if you are the last, unless necessary to make a new one.
recommended editors are talked about throughout the "favourite editor" thread in the General Discussion board.
Wldrumstcs
Forum Commoner
Posts: 98 Joined: Wed Nov 26, 2003 8:41 pm
Post
by Wldrumstcs » Thu Jan 27, 2005 8:24 pm
Sorry about not editing. I truly appreciate all your help!