Jump to content

Errors when editing BellaBiblio script


mariahneu

Recommended Posts

I'm having problems with the BellaBiblio script (http://www.jemjabella.co.uk/scripts/bellabiblio).

 

Although it is a book review script, I'm trying to modify it to turn it into a website review script, however, I modified the code in Dreamweaver and modified the current code, yet I keep receiving a "Parse error: syntax error, unexpected ')' in /home/bt4t/public_html/aaaatestingcodes/BellaBiblio/admin.php on line 248" error here: http://www.velociteen.com/aaaatestingcodes/BellaBiblio/admin.php

 

Below are the only portions of the code I modified.

 

Original admin.php file:

 

<h1 id="addbook">Enter Book Info</h1>

<form action="admin.php?ap=add_book" method="post" enctype="multipart/form-data"><p>

<select name="status" id="status"><option value="read">Read</option><option value="unread">Unread</option></select> <label for="status">Status</label><br />

<input type="text" name="isbn" id="isbn" value="<?php get_data("isbn"); ?>" /> <label for="isbn">ISBN (10-digit)</label><br />

<input type="text" name="publisher" id="publisher" value="<?php get_data("publisher"); ?>" /> <label for="publisher">Publisher</label><br />

<input type="text" name="published" id="published" value="<?php get_data("published"); ?>" maxlength="4" /> <label for="published">Year Published</label><br />

<input type="text" name="title" id="title" value="<?php get_data("title"); ?>" /> <label for="title">Book Title</label><br />

<input type="text" name="author" id="author" value="<?php get_data("author"); ?>" /> <label for="author">Author</label><br />

<input type="text" name="genre" id="genre" value="<?php get_data("genre"); ?>" /> <label for="genre">Genre</label><br />

<input type="text" name="pages" id="pages" value="<?php get_data("pages"); ?>" /> <label for="pages">Pages</label><br />

<select name="rating" id="rating"><option value="0">Unrated</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option></select> <label for="rating">Rating</label><br />

<textarea rows="5" cols="25" name="review" id="review"><?php get_data("review"); ?></textarea> <label for="review">Short Review/Synopsis</label><br />

</p>

<p><input type="submit" class="button" name="submit" id="submit" value="Add" /></p>

</form>

 

Modified admin.php file:

 

    <h1 id="addbook">Enter Website Review Info</h1>

<form action="admin.php?ap=add_book" method="post" enctype="multipart/form-data"><p>

<label for="status2"><strong>Status of Review:</strong></label>

<select name="status" id="status">

                <option value="reviewed"<?php if ($status == "reviewed") echo ' selected="selected"'; ?>>Reviewed</option>

                <option value="pending"<?php if ($status == "pending") echo ' selected="selected"'; ?>>Pending Review</option></select>

</p>

  <p><br />         

    <label for="reviewer2"><strong>Reviewer:</strong></label>

<input name="isbn" type="text" id="isbn" size="25" value="<?php echo $reviewer; ?>" />

  </p>

  <p>

  <br />

 

    <label for="date2"><strong>Date Reviewed:</strong></label>

<input name="publisher" type="text" id="publisher" size="15" value="<?php echo $date; ?>" />

      </p>

  <p><br />

    <label for="screenshot2"><strong>Link to Screenshot:</strong></label>

    <input name="published" type="text" id="published" size="50" value="<?php echo $screenshot; ?>" />

      </p>

  <p>     <br />

    <label for="title2"><strong>Title of Site:</strong></label>

  <input name="title" type="text" id="title" size="40" value="<?php echo $title; ?>" />

      </p>

  <p><br />

    <label for="link2"><strong>Link to Site:</strong></label>

  <input name="author" type="text" id="author" size="50" value="<?php echo $link; ?>" /> <label for="link"><br>

  </label>

    <br />

    <label for="author2"><strong>Owner of Site:</strong></label>

    <input name="genre" type="text" id="genre" size="25" value="<?php echo $owner; ?>" />

  </p>

  <p>     <br />

    <label for="e-mail2"><strong>Contact E-Mail:</strong></label>

    <input name="pages" type="text" id="pages" size="40" value="<?php echo $contact; ?>" />

      </p>

  <p>

    <strong>

    <label><br />

    Positive Aspects:

      <br />

      <textarea name="positive_aspects" id="positive_aspects" cols="45" rows="5"><?php echo $positive; ?></textarea>

    </label>

    </strong></p>

  <p>

    <strong>

    <label>Negative Aspects:<br />

      <textarea name="negative_aspects" id="negative_aspects" cols="45" rows="5"><?php echo $negative; ?></textarea>

        </label>

      </strong> </p>

  <table width="200" border="1">

    <caption>

      <strong>Grading Scale: </strong>

    </caption>

    <tr>

      <th scope="col">Total Score:</th>

      <th scope="col">Letter Grade:</th>

        </tr>

    <tr>

      <td>100+</td>

      <td>A+</td>

        </tr>

    <tr>

      <td>95-99</td>

      <td>A</td>

        </tr>

    <tr>

      <td>90-94</td>

      <td>A-</td>

        </tr>

    <tr>

      <td>87-89</td>

      <td>B+</td>

        </tr>

    <tr>

      <td>84-86</td>

      <td>B</td>

        </tr>

    <tr>

      <td>80-83</td>

      <td>B-</td>

        </tr>

    <tr>

      <td>77-79</td>

      <td>C+</td>

        </tr>

    <tr>

      <td>74-76</td>

      <td>C</td>

        </tr>

    <tr>

      <td>70-83</td>

      <td>C-</td>

        </tr>

    <tr>

      <td>67-69</td>

      <td>D+</td>

        </tr>

    <tr>

      <td>64-66</td>

      <td>D</td>

        </tr>

    <tr>

      <td>60-63</td>

      <td>D-</td>

        </tr>

    <tr>

      <td>0-59</td>

      <td>F</td>

        </tr>

      </table>

  <p>

    <label><strong>Originality (out of 25):</strong>

                      <input name="originality" type="text" id="originality" size="7" maxlength="2" value="<?php echo $originality; ?>" />

        </label>

  </p>

  <p>

    <strong>

    <label>Design & Visual </label>

    (out of 25)

    <label>:

  <input name="DesignVisual" type="text" id="DesignVisual" size="7" maxlength="2" value="<?php echo $design; ?>" />

        </label>

          </strong> </p>

  <p>

    <strong>

    <label>Content </label>

    (out of 25)

    <label>:

  <input name="content" type="text" id="content" size="7" maxlength="2" value="<?php echo $content; ?>" />

        </label>

          </strong> </p>

  <p>

    <strong>

    <label>Navigation </label>

    (out of 25):

    <label>

  <input name="navigation" type="text" id="navigation" size="7" maxlength="2" value="<?php echo $navigation; ?>" />

        </label>

          </strong> </p>

  <p>

    <strong>

    <label>Bonus Points (up to 25):

      <input name="bonuspoints" type="text" id="bonuspoints" size="7" maxlength="2" value="<?php echo $bonus; ?>" />

        </label>

      </strong> </p>

  <p>

    <strong>

    <label>Total Score (out of 100):

      <input name="total" type="text" id="total" size="7" maxlength="3" value="<?php echo $total; ?>" />

        </label>

      </strong> </p>

  <p>

    <label><strong>Grade:</strong>

      <select name="grade" id="grade">

        <option>"F"<?php if ($grade == F) echo ' selected="selected"'; ?>F</option>

        <option>"D-"<?php if ($grade == D) echo ' selected="selected"'; ?>D-</option>

        <option>"D"<?php if ($grade == D) echo ' selected="selected"'; ?>D</option>

        <option>"D+"<?php if ($grade == D+) echo ' selected="selected"'; ?>D+</option>

        <option>"C-"<?php if ($grade == C-) echo ' selected="selected"'; ?>C-</option>

        <option>"C"<?php if ($grade == C) echo ' selected="selected"'; ?>C</option>

        <option>"C+"<?php if ($grade == C+) echo ' selected="selected"'; ?>C+</option>

        <option>"B-"<?php if ($grade == B-) echo ' selected="selected"'; ?>B-</option>

        <option>"B"<?php if ($grade == B) echo ' selected="selected"'; ?>B</option>

        <option>"B+"<?php if ($grade == B+) echo ' selected="selected"'; ?>B+</option>

        <option>"A-"<?php if ($grade == A-) echo ' selected="selected"'; ?>A-</option>

        <option>"A"<?php if ($grade == A) echo ' selected="selected"'; ?>A</option>

        <option>"A+"<?php if ($grade == A+) echo ' selected="selected"'; ?>A+</option>

          </select>

        </label>

  </p>

<p><input type="submit" class="button" name="submit" id="submit" value="Add" /></p>

</form>

 

Original config.php file:

 

$newBooks = array();

list($status,$isbn,$publisher,$year,$title,$author,$genre,$pageamt,$rating,$review) = preg_split("/,(?! )/", $book);

$newBooks[$$sortkey.$key] = $book;

 

Modified config.php file:

 

list($status,$reviewer,$date,$screenshot,$title,$link,$owner,$contact,$positive,$negative,$originality,$design,$content,$navigation,$bonus,$total,$grade) = preg_split("/,(?! )/", $book);

$newBooks[$$sortkey.$key] = $book;

 

 

Any help is much appreciated. Thanks! =]

Link to comment
https://forums.phpfreaks.com/topic/156696-errors-when-editing-bellabiblio-script/
Share on other sites

                    <option>"F"<?php if ($grade == F) echo ' selected="selected"'; ?>F</option>
                    <option>"D-"<?php if ($grade == D) echo ' selected="selected"'; ?>D-</option>
                    <option>"D"<?php if ($grade == D) echo ' selected="selected"'; ?>D</option>
                    <option>"D+"<?php if ($grade == D+) echo ' selected="selected"'; ?>D+</option>
                    <option>"C-"<?php if ($grade == C-) echo ' selected="selected"'; ?>C-</option>
                    <option>"C"<?php if ($grade == C) echo ' selected="selected"'; ?>C</option>
                    <option>"C+"<?php if ($grade == C+) echo ' selected="selected"'; ?>C+</option>
                    <option>"B-"<?php if ($grade == B-) echo ' selected="selected"'; ?>B-</option>
                    <option>"B"<?php if ($grade == B) echo ' selected="selected"'; ?>B</option>
                    <option>"B+"<?php if ($grade == B+) echo ' selected="selected"'; ?>B+</option>
                    <option>"A-"<?php if ($grade == A-) echo ' selected="selected"'; ?>A-</option>
                    <option>"A"<?php if ($grade == A) echo ' selected="selected"'; ?>A</option>
                    <option>"A+"<?php if ($grade == A+) echo ' selected="selected"'; ?>A+</option>

 

On all those lines, you need quotes around the grade letters.

 

Example:

if ($grade == 'A+')

See the quotes?

                    <option>"F"<?php if ($grade == F) echo ' selected="selected"'; ?>F</option>
                    <option>"D-"<?php if ($grade == D) echo ' selected="selected"'; ?>D-</option>
                    <option>"D"<?php if ($grade == D) echo ' selected="selected"'; ?>D</option>
                    <option>"D+"<?php if ($grade == D+) echo ' selected="selected"'; ?>D+</option>
                    <option>"C-"<?php if ($grade == C-) echo ' selected="selected"'; ?>C-</option>
                    <option>"C"<?php if ($grade == C) echo ' selected="selected"'; ?>C</option>
                    <option>"C+"<?php if ($grade == C+) echo ' selected="selected"'; ?>C+</option>
                    <option>"B-"<?php if ($grade == B-) echo ' selected="selected"'; ?>B-</option>
                    <option>"B"<?php if ($grade == B) echo ' selected="selected"'; ?>B</option>
                    <option>"B+"<?php if ($grade == B+) echo ' selected="selected"'; ?>B+</option>
                    <option>"A-"<?php if ($grade == A-) echo ' selected="selected"'; ?>A-</option>
                    <option>"A"<?php if ($grade == A) echo ' selected="selected"'; ?>A</option>
                    <option>"A+"<?php if ($grade == A+) echo ' selected="selected"'; ?>A+</option>

 

On all those lines, you need quotes around the grade letters.

 

Example:

if ($grade == 'A+')

See the quotes?

 

That's it? Wow, I feel like an idiot right now... Thank you. :)

 

Now, I can access the admin area, however, when I submit the form, I receive an "ERROR:

Invalid status - read or unread only." message at the top of the page at http://www.velociteen.com/aaaatestingcodes/BellaBiblio/admin.php?ap=add_book

 

The fields are also filled with coding that is of this nature:

 

<br /> <b>Notice</b>:  Undefined variable: reviewer in <b>/home/bt4t/public_html/aaaatestingcodes/BellaBiblio/admin.php</b> on line <b>95</b><br />

The way you're defining it is in the config.php file. Problem is, does $book have all those params. Can you do:

var_dump($book);

in your config.php file? Post the result here. I'm guessing you need to modify $book somewhere. I'm guessing you're using MySQL to pull the information for $book right? Can you post that code?

The way you're defining it is in the config.php file. Problem is, does $book have all those params. Can you do:

var_dump($book);

in your config.php file? Post the result here. I'm guessing you need to modify $book somewhere. I'm guessing you're using MySQL to pull the information for $book right? Can you post that code?

 

define("BOOKS", "books.txt");

define("RECBOOKS", "rec-books.txt");

 

function cleanUp($text) {

$text = strip_tags($text);

$text = repCommas(trim(htmlentities($text)));

 

if (!get_magic_quotes_gpc())

$text = addslashes($text);

 

return $text;

}

function repCommas($input) {

return str_replace(",", "|", $input);

}

function fixCommas($input) {

return str_replace("|", ",", $input);

}

function blanklinefix($inputfile) {

ignore_user_abort(true);

$content = file($inputfile);

 

if (count($content) > 0) {

$content = array_diff(array_diff($content, array("")), array("\n"));

 

$newContent = array();

foreach ($content as $line) {

$newContent[] = trim($line);

}

$newContent = implode("\n", $newContent);

 

$fl = fopen($inputfile, "w+");

if (flock($fl, LOCK_EX)) {

fwrite($fl, $newContent);

flock($fl, LOCK_UN);

} else {

echo 'The file: '.$inputfile.' could not be locked for writing; the blanklinefix function could not be applied at this time.';

}

fclose($fl);

}

ignore_user_abort(false);

}

function get_data($var) {

global $c;

if (isset($c[$var])) {

echo $c[$var];

}

}

function sort_array($array, $sortkey, $sorttype) {

if ($sortkey == "review") exit("<p>I told ya not to sort by review, are you trying to be smart?!</p>");

 

$newBooks = array();

var_dump($book);

foreach ($array as $key => $book) {

$key = str_pad($key, 3, "0", STR_PAD_LEFT);

list($status,$reviewer,$date,$screenshot,$title,$link,$owner,$contact,$positive,$negative,$originality,$design,$content,$navigation,$bonus,$total,$grade) = preg_split("/,(?! )/", $book);

$newBooks[$$sortkey.$key] = $book;

}

if ($sorttype == "ksort") ksort($newBooks); elseif ($sorttype == "krsort") krsort($newBooks);

return array_values($newBooks);

}

function breakEmail($email) {

$email = str_replace('.', 'DOTTY', $email);

$email = str_replace('@', 'ATTIE', $email);

$email = str_replace('-', 'DASHY', $email);

$email = str_replace('_', 'SCORE', $email);

 

return $email;

}

function fixEmail($email) {

$email = str_replace('DOTTY', '.', $email);

$email = str_replace('ATTIE', '@', $email);

$email = str_replace('DASHY', '-', $email);

$email = str_replace('SCORE', '_', $email);

 

return $email;

}

 

blanklinefix(BOOKS);

blanklinefix(RECBOOKS);

error_reporting(E_ALL);

?>

Do you get an output from var_dump($book)?

 

I don't know how to define it. Why? Because I don't know what it is. To me, it's just an arbitrary variable. You'll have to find where it's defined. It should look something like this:

 

$book = SOMETHING_HERE;

Of course, SOMETHING_HERE isn't literal. I just mean there's something there but I don't know what it is. Just look for "$book =" or "$book=". Not sure if there is a space or not.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.