Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 24

Thread: Error help

  1. #1
    New Coder
    Join Date
    Feb 2010
    Posts
    43
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Error help

    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 Code:
     <?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";
    }
    ?>

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Posts
    301
    Thanks
    7
    Thanked 2 Times in 2 Posts
    Answered: PHP Math

    Quote Originally Posted by MattyUK View Post
    Try removing the extra } on line 85.
    I know you checked with JEdit 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 Code:
     <?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

  • #3
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,471
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    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 Code:
     <?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"
       }

    ?>

  • #4
    New Coder
    Join Date
    Feb 2010
    Posts
    43
    Thanks
    9
    Thanked 0 Times in 0 Posts
    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";
    }
    }
    ?>

  • #5
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Try
    Code:
    if($_GET['id'] && ctype_digit($_GET['id'])){
    	mysql_query("DELETE FROM reps WHERE id = {$_GET['id']}") or die(mysql_error());
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #6
    Regular Coder
    Join Date
    Jul 2002
    Posts
    301
    Thanks
    7
    Thanked 2 Times in 2 Posts
    String encapsulation problem on line 91.

    This part:
    PHP Code:
    '$_GET['id']' 
    of this line:
    PHP Code:
    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:
    PHP Code:
    DELETE FROM reps WHERE id '4' 
    PHP Code:
    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/languag....syntax.single
    http://www.php.net/manual/en/languag....syntax.double


    PS:
    Ahh, abduraooft is kinder than I.
    Last edited by MattyUK; 03-11-2010 at 12:02 PM. Reason: PS

  • #7
    New Coder
    Join Date
    Feb 2010
    Posts
    43
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Hopefully the last one..

    Parse error: syntax error, unexpected T_ECHO in /home/sbdthru/public_html/repcp.php on line 96
    PHP Code:
     <?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";  
       } 
    }  
    ?>

  • #8
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Look over your code around there and you'll see something obvious.

    Hint: Look at line
    PHP Code:
    mysql_query("DELETE FROM reps WHERE id = {$_GET['id']}") or die(mysql_error()) 

  • #9
    New Coder
    Join Date
    Feb 2010
    Posts
    43
    Thanks
    9
    Thanked 0 Times in 0 Posts
    PHP Code:
    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

  • #10
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,253
    Thanks
    12
    Thanked 341 Times in 337 Posts
    that's correct, there's something important missing.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #11
    New Coder
    Join Date
    Feb 2010
    Posts
    43
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Dormilich View Post
    that's correct, there's something important missing.
    PHP Code:
    <?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...";  
     }
    }  
    ?>

  • #12
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,253
    Thanks
    12
    Thanked 341 Times in 337 Posts
    take a close look at the end of the line ...
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #13
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    PHP Code:
    mysql_query("DELETE FROM reps WHERE id = '".$_GET['id']."") or die(mysql_error()) 
    Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?

  • #14
    Regular Coder
    Join Date
    Jul 2002
    Posts
    301
    Thanks
    7
    Thanked 2 Times in 2 Posts
    Made me smile ;)

  • #15
    New Coder
    Join Date
    Feb 2010
    Posts
    43
    Thanks
    9
    Thanked 0 Times in 0 Posts
    ... Which gave me

    Parse error: syntax error, unexpected T_ECHO in /home/sbdthru/public_html/repcp.php on line 96
    PHP Code:
     <?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...";  
     }
    }
    ?>


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •