...

View Full Version : Error help



SBDTHRU
03-11-2010, 04:12 AM
This code is giving me real problems. I keep getting


Parse error: syntax error, unexpected T_CASE in /home/sbdthru/public_html/repcp.php on line 86

I've tried everything.. No extra whitespace that I can find, no extra {}.. It's really frustrating me.


<?php
ob_start();
include("config.php");
switch($_GET[x]){
default:
if ($logged[username] && $logged[level] == Admin){
$get = mysql_query("SELECT * FROM reps") or die(mysql_error());
$gnum = mysql_num_rows($get);
if($gnum == 0){
$prev = stripslashes(htmlspecialchars(trim($_POST['prev'],'$ ')));
$reason = stripslashes(htmlspecialchars(trim($_POST['reason'],'$ ')));
//We can only use them if they are valid numbers, so lets test
if(is_numeric($prev))
{ //yep a number
$prev = floatval($prev);
}
else
{ //nah, bad input so zero it out
$prev = 0.00;
}
if(is_numeric($reason))
{ //yep a number
$reason = floatval($reason);
}
else
{ //nah, bad input so zero it out
$reason = 0.00;
}
//the php math part
$dif = round($reason - $prev,2);
echo '<form method="post" action="'.$_SERVER["PHP_SELF"].'" >
<font type="verdana" size="2"><body link="white" alink="white" vlink="white"><b>Error</b>: There Are No Reports To Review";
}else{
echo "<font type="verdana" size="2"><body link="white" alink="white" vlink="white">There Are Currently $gnum Reports To Review<br>";
while($ec = mysql_fetch_array($get)){
echo "<table width="500" align="center">

<tr>
<td width="150" align="left" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black"></b><br />
&nbsp;<b>Reported By</b>: $ec[reported_by]
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Site</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">$ec[name]
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Username</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">$ec[username]
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Current Bankroll</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">.htmlspecialchars($reason).
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Previous Bankroll</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">.htmlspecialchars($prev).
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Bankroll Change</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">.htmlspecialchars($dif).
</td>
</tr>
<tr>

<td width="200" colspan="2" align="center" valign="top">
<font type="verdana" size="2"><body link="black" alink="black" vlink="black"><a href="repcp.php?x=delete&id=$ec[id]">Delete</a>
</td>
</tr>
</table>
<hr width="65%">';
}
}
}
break;
case "delete" :
if($_GET['id']){
mysql_query("DELETE FROM reps WHERE id = '$_GET['id']'") or die(mysql_error());
echo "<meta http-equiv=\"Refresh\" content=\"0; URL=repcp.php\"/>Report Deleted. Redirecting...";
} else {
echo "<b>Error</b>: No Report Was Selected To Delete";
}
?>

MattyUK
03-11-2010, 04:45 AM
Answered: http://www.codingforums.com/showpost.php?p=928294&postcount=13


Try removing the extra } on line 85.


I know you checked with JEdit (http://www.codingforums.com/showpost.php?p=929045&postcount=16) but maybe JEdit isn't doing it right?? You have {} encapsulated within the string. I'd wager it may be getting mixed up.

Try manually indenting and formatting formally. I also include a comment for each closing bracket to help in cases like this. Maybe it'd be easier to spot in this revised version below:


<?php
ob_start();
include("config.php");
switch($_GET[x]){
default:
if ($logged[username] && $logged[level] == Admin){
$get = mysql_query("SELECT * FROM reps") or die(mysql_error());
$gnum = mysql_num_rows($get);
if($gnum == 0){
$prev = stripslashes(htmlspecialchars(trim($_POST['prev'],'$ ')));
$reason = stripslashes(htmlspecialchars(trim($_POST['reason'],'$ ')));
//We can only use them if they are valid numbers, so lets test
if(is_numeric($prev))
{ //yep a number
$prev = floatval($prev);
}
else
{ //nah, bad input so zero it out
$prev = 0.00;
}
if(is_numeric($reason))
{ //yep a number
$reason = floatval($reason);
}
else
{ //nah, bad input so zero it out
$reason = 0.00;
}
//the php math part
$dif = round($reason - $prev,2);
echo '<form method="post" action="'.$_SERVER["PHP_SELF"].'" >
<font type="verdana" size="2"><body link="white" alink="white" vlink="white"><b>Error</b>: There Are No Reports To Review";
}else{
echo "<font type="verdana" size="2"><body link="white" alink="white" vlink="white">There Are Currently $gnum Reports To Review<br>";
while($ec = mysql_fetch_array($get)){
echo "<table width="500" align="center">

<tr>
<td width="150" align="left" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black"></b><br />
&nbsp;<b>Reported By</b>: $ec[reported_by]
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Site</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">$ec[name]
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Username</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">$ec[username]
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Current Bankroll</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">.htmlspecialchars($reason).
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Previous Bankroll</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">.htmlspecialchars($prev).
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Bankroll Change</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">.htmlspecialchars($dif).
</td>
</tr>
<tr>

<td width="200" colspan="2" align="center" valign="top">
<font type="verdana" size="2"><body link="black" alink="black" vlink="black"><a href="repcp.php?x=delete&id=$ec[id]">Delete</a>
</td>
</tr>
</table>
<hr width="65%">';
}//from: if($gnum == 0){
}//from: if ($logged[username] && $logged[level] == Admin){
}//from: switch($_GET[x]){
break;
case "delete" :
if($_GET['id']){
mysql_query("DELETE FROM reps WHERE id = '$_GET['id']'") or die(mysql_error());
echo "<meta http-equiv=\"Refresh\" content=\"0; URL=repcp.php\"/>Report Deleted. Redirecting...";
}
else {
echo "<b>Error</b>: No Report Was Selected To Delete";
}
?>

(not fixed just highlighted to show value of formatting). Try putting it into Notepad++ and looking at line 84.

best wishes
Matt

mlseim
03-11-2010, 04:45 AM
Misplaced {

This is where indenting code is important ... so you can see the { sections }.
Also, if you edit using Notepad++, that software highlights all ( ) and { } pairs.



<?php
ob_start();
include("config.php");

switch($_GET[x]){

default:
if ($logged[username] && $logged[level] == Admin){
$get = mysql_query("SELECT * FROM reps") or die(mysql_error());
$gnum = mysql_num_rows($get);

if($gnum == 0){
$prev = stripslashes(htmlspecialchars(trim($_POST['prev'],'$ ')));
$reason = stripslashes(htmlspecialchars(trim($_POST['reason'],'$ ')));
//We can only use them if they are valid numbers, so lets test
if(is_numeric($prev)){
//yep a number
$prev = floatval($prev);
}
else {
//nah, bad input so zero it out
$prev = 0.00;
}

if(is_numeric($reason)){
//yep a number
$reason = floatval($reason);
}
else{ //nah, bad input so zero it out
$reason = 0.00;
}

//the php math part
$dif = round($reason - $prev,2);

echo '<form method="post" action="'.$_SERVER["PHP_SELF"].'" >
<font type="verdana" size="2"><body link="white" alink="white" vlink="white"><b>Error</b>: There Are No Reports To Review";
}else{
echo "<font type="verdana" size="2"><body link="white" alink="white" vlink="white">There Are Currently $gnum Reports To Review<br>";
while($ec = mysql_fetch_array($get)){
echo "<table width="500" align="center">

<tr>
<td width="150" align="left" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black"></b><br />
&nbsp;<b>Reported By</b>: $ec[reported_by]
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Site</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">$ec[name]
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Username</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">$ec[username]
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Current Bankroll</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">.htmlspecialchars($reason).
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Previous Bankroll</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">.htmlspecialchars($prev).
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Bankroll Change</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">.htmlspecialchars($dif).
</td>
</tr>
<tr>

<td width="200" colspan="2" align="center" valign="top">
<font type="verdana" size="2"><body link="black" alink="black" vlink="black"><a href="repcp.php?x=delete&id=$ec[id]">Delete</a>
</td>
</tr>
</table>
<hr width="65%">';

}
}
break;

case "delete" :

if($_GET['id']){
mysql_query("DELETE FROM reps WHERE id = '$_GET['id']'") or die(mysql_error());
echo "<meta http-equiv=\"Refresh\" content=\"0; URL=repcp.php\"/>Report Deleted. Redirecting...";
} else {
echo "<b>Error</b>: No Report Was Selected To Delete";
}
}
?>

SBDTHRU
03-11-2010, 05:43 AM
Hmm. Solved that problem. But getting


Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/sbdthru/public_html/repcp.php on line 91


<?php
ob_start();
include("config.php");
switch($_GET[x]){
default:
if ($logged[username] && $logged[level] == Admin){
$get = mysql_query("SELECT * FROM reps") or die(mysql_error());
$gnum = mysql_num_rows($get);

if($gnum == 0){
$prev = stripslashes(htmlspecialchars(trim($_POST['prev'],'$ ')));
$reason = stripslashes(htmlspecialchars(trim($_POST['reason'],'$ ')));
//We can only use them if they are valid numbers, so lets test
if(is_numeric($prev)){
//yep a number
$prev = floatval($prev);
}
else {
//nah, bad input so zero it out
$prev = 0.00;
}

if(is_numeric($reason)){
//yep a number
$reason = floatval($reason);
}
else{ //nah, bad input so zero it out
$reason = 0.00;
}

//the php math part
$dif = round($reason - $prev,2);

echo '<form method="post" action="'.$_SERVER["PHP_SELF"].'" >
<font type="verdana" size="2"><body link="white" alink="white" vlink="white"><b>Error</b>: There Are No Reports To Review";
}else{
echo "<font type="verdana" size="2"><body link="white" alink="white" vlink="white">There Are Currently $gnum Reports To Review<br>";
while($ec = mysql_fetch_array($get)){
echo "<table width="500" align="center">

<tr>
<td width="150" align="left" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black"></b><br />
&nbsp;<b>Reported By</b>: $ec[reported_by]
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Site</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">$ec[name]
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Username</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">$ec[username]
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Current Bankroll</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">.htmlspecialchars($reason).
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Previous Bankroll</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">.htmlspecialchars($prev).
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Bankroll Change</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">.htmlspecialchars($dif).
</td>
</tr>
<tr>

<td width="200" colspan="2" align="center" valign="top">
<font type="verdana" size="2"><body link="black" alink="black" vlink="black"><a href="repcp.php?x=delete&id=$ec[id]">Delete</a>
</td>
</tr>
</table>
<hr width="65%">';

}
}
break;
case "delete" :
if($_GET['id']){
mysql_query("DELETE FROM reps WHERE id = '$_GET['id']'") or die(mysql_error());
echo "<meta http-equiv=\"Refresh\" content=\"0; URL=repcp.php\"/>Report Deleted. Redirecting...";
} else {
echo "<b>Error</b>: No Report Was Selected To Delete";
}
}
?>

abduraooft
03-11-2010, 08:44 AM
Try
if($_GET['id'] && ctype_digit($_GET['id'])){
mysql_query("DELETE FROM reps WHERE id = {$_GET['id']}") or die(mysql_error());

MattyUK
03-11-2010, 01:00 PM
String encapsulation problem on line 91.

This part:

'$_GET['id']'
of this line:

mysql_query("DELETE FROM reps WHERE id = '$_GET['id']'") or die(mysql_error());
may be the issue.

You may find the query that you intended to read as:

DELETE FROM reps WHERE id = '4'


DELETE FROM reps WHERE id = '$_GET['

I'm hesitant to give you the code answer (assuming I'm correct in thinking what it is) because I know you'll need to understand the different types of strings very well and most people learn from their own conclusions better than ones given to them.

Are these pointers enough?
http://php.net/manual/en/language.types.string.php
http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.single
http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double


PS:
Ahh, abduraooft is kinder than I.

SBDTHRU
03-11-2010, 01:40 PM
Hopefully the last one..


Parse error: syntax error, unexpected T_ECHO in /home/sbdthru/public_html/repcp.php on line 96


<?php
ob_start();
include("config.php");

switch($_GET[x]){

default:
if ($logged[username] && $logged[level] == Admin){
$get = mysql_query("SELECT * FROM reps") or die(mysql_error());
$gnum = mysql_num_rows($get);

if($gnum == 0){
$prev = stripslashes(htmlspecialchars(trim($_POST['prev'],'$ ')));
$reason = stripslashes(htmlspecialchars(trim($_POST['reason'],'$ ')));
//We can only use them if they are valid numbers, so lets test
if(is_numeric($prev)){
//yep a number
$prev = floatval($prev);
}
else {
//nah, bad input so zero it out
$prev = 0.00;
}

if(is_numeric($reason)){
//yep a number
$reason = floatval($reason);
}
else{ //nah, bad input so zero it out
$reason = 0.00;
}

//the php math part
$dif = round($reason - $prev,2);

echo '<form method="post" action="'.$_SERVER["PHP_SELF"].'" >
<font type="verdana" size="2"><body link="white" alink="white" vlink="white"><b>Error</b>: There Are No Reports To Review";
}else{
echo "<font type="verdana" size="2"><body link="white" alink="white" vlink="white">There Are Currently $gnum Reports To Review<br>";
while($ec = mysql_fetch_array($get)){
echo "<table width="500" align="center">

<tr>
<td width="150" align="left" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black"></b><br />
&nbsp;<b>Reported By</b>: $ec[reported_by]
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Site</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">$ec[name]
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Username</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">$ec[username]
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Current Bankroll</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">.htmlspecialchars($reason).
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Previous Bankroll</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">.htmlspecialchars($prev).
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Bankroll Change</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">.htmlspecialchars($dif).
</td>
</tr>
<tr>

<td width="200" colspan="2" align="center" valign="top">
<font type="verdana" size="2"><body link="black" alink="black" vlink="black"><a href="repcp.php?x=delete&id=$ec[id]">Delete</a>
</td>
</tr>
</table>
<hr width="65%">';

}
}
break;

case "delete" :

if($_GET['id'] && ctype_digit($_GET['id'])){
mysql_query("DELETE FROM reps WHERE id = {$_GET['id']}") or die(mysql_error())
echo"<meta http-equiv=\"Refresh\" content=\"0; URL=repcp.php\"/>Report Deleted. Redirecting...";
} else {
echo "<b>Error</b>: No Report Was Selected To Delete";
}
}
?>

Nightfire
03-11-2010, 01:44 PM
Look over your code around there and you'll see something obvious.

Hint: Look at line


mysql_query("DELETE FROM reps WHERE id = {$_GET['id']}") or die(mysql_error())

SBDTHRU
03-11-2010, 09:21 PM
mysql_query("DELETE FROM reps WHERE id = $_GET['id']") or die(mysql_error())

Does that look right? It went back to giving me


Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/sbdthru/public_html/repcp.php on line 95

Dormilich
03-11-2010, 09:32 PM
that's correct, there's something important missing.

SBDTHRU
03-11-2010, 09:44 PM
that's correct, there's something important missing.


<?php
ob_start();
include("config.php");

switch($_GET[x]){

default:
if ($logged[username] && $logged[level] == Admin){
$get = mysql_query("SELECT * FROM reps") or die(mysql_error());
$gnum = mysql_num_rows($get);

if($gnum == 0){
$prev = stripslashes(htmlspecialchars(trim($_POST['prev'],'$ ')));
$reason = stripslashes(htmlspecialchars(trim($_POST['reason'],'$ ')));
//We can only use them if they are valid numbers, so lets test
if(is_numeric($prev)){
//yep a number
$prev = floatval($prev);
}
else {
//nah, bad input so zero it out
$prev = 0.00;
}

if(is_numeric($reason)){
//yep a number
$reason = floatval($reason);
}
else{ //nah, bad input so zero it out
$reason = 0.00;
}

//the php math part
$dif = round($reason - $prev,2);

echo '<form method="post" action="'.$_SERVER["PHP_SELF"].'" >
<font type="verdana" size="2"><body link="white" alink="white" vlink="white"><b>Error</b>: There Are No Reports To Review";
}else{
echo "<font type="verdana" size="2"><body link="white" alink="white" vlink="white">There Are Currently $gnum Reports To Review<br>";
while($ec = mysql_fetch_array($get)){
echo "<table width="500" align="center">

<tr>
<td width="150" align="left" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black"></b><br />
&nbsp;<b>Reported By</b>: $ec[reported_by]
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Site</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">$ec[name]
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Username</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">$ec[username]
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Current Bankroll</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">.htmlspecialchars($reason).
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Previous Bankroll</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">.htmlspecialchars($prev).
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Bankroll Change</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">.htmlspecialchars($dif).
</td>
</tr>
<tr>

<td width="200" colspan="2" align="center" valign="top">
<font type="verdana" size="2"><body link="black" alink="black" vlink="black"><a href="repcp.php?x=delete&id=$ec[id]">Delete</a>
</td>
</tr>
</table>
<hr width="65%">';

}
}
break;

case "delete" :

if($_GET['id'] && ctype_digit($_GET['id'])){
mysql_query("DELETE FROM reps WHERE id = '$_GET['id']'") or die(mysql_error())
echo "<meta http-equiv=\"Refresh\" content=\"0; URL=repcp.php\"/>Report Deleted. Redirecting...";
}
}
?>

Dormilich
03-11-2010, 09:50 PM
take a close look at the end of the line ...

masterofollies
03-11-2010, 11:36 PM
mysql_query("DELETE FROM reps WHERE id = '".$_GET['id']."") or die(mysql_error())

MattyUK
03-12-2010, 12:24 AM
Made me smile ;)

SBDTHRU
03-12-2010, 02:48 AM
... Which gave me


Parse error: syntax error, unexpected T_ECHO in /home/sbdthru/public_html/repcp.php on line 96


<?php
ob_start();
include("config.php");

switch($_GET[x]){

default:
if ($logged[username] && $logged[level] == Admin){
$get = mysql_query("SELECT * FROM reps") or die(mysql_error());
$gnum = mysql_num_rows($get);

if($gnum == 0){
$prev = stripslashes(htmlspecialchars(trim($_POST['prev'],'$ ')));
$reason = stripslashes(htmlspecialchars(trim($_POST['reason'],'$ ')));
//We can only use them if they are valid numbers, so lets test
if(is_numeric($prev)){
//yep a number
$prev = floatval($prev);
}
else {
//nah, bad input so zero it out
$prev = 0.00;
}

if(is_numeric($reason)){
//yep a number
$reason = floatval($reason);
}
else{ //nah, bad input so zero it out
$reason = 0.00;
}

//the php math part
$dif = round($reason - $prev,2);

echo '<form method="post" action="'.$_SERVER["PHP_SELF"].'" >
<font type="verdana" size="2"><body link="white" alink="white" vlink="white"><b>Error</b>: There Are No Reports To Review";
}else{
echo "<font type="verdana" size="2"><body link="white" alink="white" vlink="white">There Are Currently $gnum Reports To Review<br>";
while($ec = mysql_fetch_array($get)){
echo "<table width="500" align="center">

<tr>
<td width="150" align="left" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black"></b><br />
&nbsp;<b>Reported By</b>: $ec[reported_by]
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Site</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">$ec[name]
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Username</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">$ec[username]
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Current Bankroll</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">.htmlspecialchars($reason).
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Previous Bankroll</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">.htmlspecialchars($prev).
</td>
</tr>

<tr>
<td width="200" colspan="2" align="center" valign="top">
<b><font type="verdana" size="2"><body link="black" alink="black" vlink="black">Bankroll Change</b>: <font type="verdana" size="2"><body link="black" alink="black" vlink="black">.htmlspecialchars($dif).
</td>
</tr>
<tr>

<td width="200" colspan="2" align="center" valign="top">
<font type="verdana" size="2"><body link="black" alink="black" vlink="black"><a href="repcp.php?x=delete&id=$ec[id]">Delete</a>
</td>
</tr>
</table>
<hr width="65%">';

}
}
break;

case "delete" :

if($_GET['id'] && ctype_digit($_GET['id'])){
mysql_query("DELETE FROM reps WHERE id = '".$_GET['id']."") or die(mysql_error())
echo "<meta http-equiv=\"Refresh\" content=\"0; URL=repcp.php\"/>Report Deleted. Redirecting...";
}
}
?>

masterofollies
03-12-2010, 04:47 AM
I found your error. This is the last one in your script.

Change this

echo "<meta http-equiv=\"Refresh\" content=\"0; URL=repcp.php\"/>Report Deleted. Redirecting...";

to this

echo '<meta http-equiv="Refresh" content="0" URL="repcp.php">Report Deleted. Redirecting...';

else try this

echo "<meta http-equiv=\"Refresh\" content=\"0\"; URL=\"repcp.php\" />Report Deleted. Redirecting...";

SBDTHRU
03-12-2010, 04:56 AM
:confused: Neither of those worked. It's really strange, I don't feel like there is anything wrong with the code because I have the same exact thing in other files.

MattyUK
03-12-2010, 05:04 AM
I'd wager not quite exactly as in other files. As previous kind posters mentioned it is really obvious and really simple. Best of all you know exactly where to look thanks to the error message. Look again after a nights sleep.

---

$doh='.&#'.'59;)';
echo 'TaDah <strong>'.$doh[strlen($doh)-2].'</strong>)';

Dormilich
03-12-2010, 06:32 AM
there’s still the same problem at the end of the line.

abduraooft
03-12-2010, 07:50 AM
Parse error: syntax error, unexpected T_ECHO in /home/sbdthru/public_html/repcp.php on line 96 That error indicates the 95th line is incomplete! Look at the end of that line.

masterofollies
03-12-2010, 04:47 PM
Good catch abdura.

This is the right one

mysql_query("DELETE FROM reps WHERE id = '".$_GET['id']."") or die(mysql_error());

Nightfire
03-12-2010, 05:09 PM
Good catch abdura.

This is the right one

mysql_query("DELETE FROM reps WHERE id = '".$_GET['id']."") or die(mysql_error());

That's what's been said since post 8 ;)

There's also an error there...


mysql_query("DELETE FROM reps WHERE id = '".$_GET['id']."'") or die(mysql_error());

SBDTHRU
03-13-2010, 08:38 PM
Well I'm not getting any errors, but nothing comes up. It's just blank.

abduraooft
03-14-2010, 08:17 PM
There's a sticky thread in this PHP forum, named "PHP FAQs" or so. Check the first point mentioned there.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum