I am getting this error:

Parse error: syntax error, unexpected T_RETURN in /home/myler/public_html/green-buy.info/photo/functions.php on line 9

and do now know how to fix it. I have searched and tried a few things that didn't work, so now I am just lost.

Code:

<?php

 Return (1);
 function include404(){
 function get_template($id){
   $loadingq=mysql_query("SELECT * FROM `templates` WHERE `id` = '".$id."'");
   $loading=mysql_fetch_assoc($loadingq);
stripslashes
Return ($loading()) function include_text($text){
   $GLOBALS+=get_defined_vars();
 function login_formecho "<html>\n"($showjs = false){
   echo "<s";
   echo "tyle>\nbody,td,th {\n  font-family: Verdana, Arial, Helvetica, sans-serif;\n   font-size: 10px;\n  color: #000000;\n}\n</style>\n";
   if ($showjs==showjs) {
      echo "<script>alert('Invalid Password Specified');</script>";
   }
   echo "<center>\n<a href="http://psa.com" target="_blank"><img src="images/logo.png" border=0 alt="PSA"></a>\n<br/><br/>\n<h2>Login to PSA</h2><br/><br/>\n<form method="POST" action="index.php">\nPassword: <input type="password" name="adminpass"> <input type="submit" value="Login">\n</form>\n</center>\n</html>\n";
 function delete_category($id){
   $query=mysql_query("SELECT * FROM `photos` WHERE `category` = '".$id."'");
   while (0<mysql_affected_rows()) {
      while ($row=mysql_fetch_assoc($query)) {
         $row()unlink$row;
      mysql_query("DELETE FROM `photos` WHERE `category` = '".$id."'");
      mysql_query("DELETE FROM `photo_cats` WHERE `id` = '".$id."' LIMIT 1");
      mysql_query("DELETE FROM `apps` WHERE `imgcategory` = '".$id."'");
 function delete_photo($id){
   $query=mysql_query("SELECT * FROM `photos` WHERE `id` = '".$id."' LIMIT 1");
   $row=mysql_fetch_assoc($query);
   $row()unlink$row;
   mysql_query("DELETE FROM `photos` WHERE `id` = '".$id."' LIMIT 1");
 function add_category($name){
   mysql_query("INSERT INTO `photo_cats` VALUES(null,'".addslashes($name)."')");
   echo "<font color="green">Category added to database...</font><br/><br/>";
 function delete_app($id){
   mysql_query("DELETE FROM `apps` WHERE `id` = '".$id."' LIMIT 1");
   mysql_query("DELETE FROM `landings` WHERE `app` = '".$id."' LIMIT 1");
?>

http://green-buy.info/error.txt

I get syntax errors and expect the same thing on lines 11, 17, 22, 29, 33, and 38 as well.

Can anyone fix this for me please?

As always I have AdWords and Facebook vouchers for any help. TIA

share|improve this question
1  
1) Please post your code here 2) That's completely invalid gibberish, a single return is not your only problem. Fixing that pretty much means rewriting it. – deceze Aug 25 '11 at 6:08
2  
It's a mess, not a valid PHP code... – Xaerxess Aug 25 '11 at 6:09
Where did you get that code? What is this? $row()unlink$row; What is this? stripslashes. Why are't the "'s in echo "<center>\n<a href="http. Why is there no end to any of your functions? Who wrote this? Was their first programming language Malbolge? Is PHP their second language? – ascii-lime Aug 25 '11 at 6:14
2  
The only kind thing to do to this code is euthanise it. It's utterly dreadful on every level. – GordonM Aug 25 '11 at 8:33
feedback

closed as not a real question by mario, Yoshi, GordonM, Tim Post Aug 25 '11 at 8:51

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, see the FAQ.

1 Answer

You are missing semi colons on the line before. Also you are not closing any of your functions with a closing brace }

The are still may other additional errors with this code. Have you thought of using an IDE that gives you syntax highlighting to help you find all the problems with this code? Take a look at phpstorm from JetBrains or Microsoft Expression, or Eclipse or Komodo....

This version of the code passes atleast editor parsing

<?php
                 function include404()
{
    Return (1);
}

function get_template($id)
{

    // This query is vulnerable to SQL Injection
    $loadingq = mysql_query("SELECT * FROM `templates` WHERE `id` = '" . $id . "'");
    $loading = mysql_fetch_assoc($loadingq);
    // next line commented as not a legal statement what are you trying to do here?
    // stripslashes
    Return ($loading);
}

function include_text($text)
{
    $GLOBALS += get_defined_vars();
}

function login_form($showjs = false)
{
    echo "<html>\n";
    echo "<style>\nbody,td,th {\n   font-family: Verdana, Arial, Helvetica, sans-serif;\n   font-size: 10px;\n  color: #000000;\n}\n</style>\n";
    if ($showjs) {
        echo "<script>alert('Invalid Password Specified');</script>";
    }
    echo "<center>\n<a href=\"http://psa.com\" target=\"_blank\"><img src=\"images/logo.png\" border=0 alt=\"PSA\"></a>\n<br/><br/>\n<h2>Login to PSA</h2><br/><br/>\n<form method=\"POST\" action=\"index.php\">\nPassword: <input type=\"password\" name=\"adminpass\"> <input type=\"submit\" value=\"Login\">\n</form>\n</center>\n</html>\n";
}

function delete_category($id)
{
    $query = mysql_query("SELECT * FROM `photos` WHERE `category` = '" . $id . "'");
    /* Next bit seems unneeded
       while (0<mysql_affected_rows()) {
       while ($row=mysql_fetch_assoc($query)) {
          $row()unlink$row;
    */
    mysql_query("DELETE FROM `photos` WHERE `category` = '" . $id . "'");
    mysql_query("DELETE FROM `photo_cats` WHERE `id` = '" . $id . "' LIMIT 1");
    mysql_query("DELETE FROM `apps` WHERE `imgcategory` = '" . $id . "'");
}

function delete_photo($id)
{
    /* Unneeded ?

  $query=mysql_query("SELECT * FROM `photos` WHERE `id` = '".$id."' LIMIT 1");
  $row=mysql_fetch_assoc($query);
  $row()unlink$row;
    */
    mysql_query("DELETE FROM `photos` WHERE `id` = '" . $id . "' LIMIT 1");
}

function add_category($name)
{
    mysql_query("INSERT INTO `photo_cats` VALUES(null,'" . addslashes($name) . "')");
    echo "<font color=\"green\">Category added to database...</font><br/><br/>";
}

function delete_app($id)
{
    mysql_query("DELETE FROM `apps` WHERE `id` = '" . $id . "' LIMIT 1");
    mysql_query("DELETE FROM `landings` WHERE `app` = '" . $id . "' LIMIT 1");
}

?>
share|improve this answer
3  
+1 About as helpful an answer as anyone could give to this question. – ascii-lime Aug 25 '11 at 6:26
1  
You did a great job on this, I applaud your patience and have voted accordingly. Please don't take my closing of this question as an indication that you answer and time spent isn't appreciated. – Tim Post Aug 25 '11 at 8:51
feedback

Not the answer you're looking for? Browse other questions tagged or ask your own question.