Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules
Author Message
rogue3
Regular
Regular



Joined: Jul 02, 2009
Posts: 71

PostPosted: Fri Sep 11, 2009 3:08 pm Reply with quote

I'm running into a bit of trouble getting my review to recognize a field I want to add.

I'm adding the field to my main reviews section in the database, the same one that holds all of the information that you enter when inserting a review on the 'write a review' page.

The new field is called 'keywords' and I'm using it to help when searching. This will be an invisable field in the review and only exist in the database so the search can look at it when narrowing the search down.

I was able to add it OK to the 'write' page. But, when I go to the 'preview' page that is where I'm getting stuck.

Here are the lines of code I added in the function PreviewReview with all of the other fields:

Code:
    $keywords = stripslashes($keywords);


then further down:
Code:
echo "<b>Keywords:</b> $keywords<br>";


Then at the end:
Code:
<input type=\"hidden\" name=\"keywords\" value=\"$keywords\">


And lastly, at the top I add it:
Code:
function PreviewReview($date, $title, $text, $reviewer, $email, $score, $cover, $url, $url_title, $hits, $id, $rlanguage, $category, $keywords)


I think this is where the problem is occurring. Anywhere I add it at the top and it messes up the data. Are these in a special order? Am I missing something? I tried to set the field up just like the title field and patterened all of the code after that. But, it doesn't seem to work.

So, the full final function looks like this:
Code:
function PreviewReview($date, $title, $text, $reviewer, $email, $score, $cover, $url, $url_title, $hits, $id, $rlanguage, $category, $keywords) {

    global $admin, $db, $multilingual, $module_name, $prefix;
    if (eregi("<!--pagebreak-->", $text)) {
      $text = ereg_replace("<!--pagebreak-->","&lt;!--pagebreak--&gt;",$text);
    }
    $title = stripslashes(check_html($title, "nohtml"));
    $text = stripslashes($text);
    $category = intval($category);
    $reviewer = stripslashes(check_html($reviewer, "nohtml"));
    $url_title = stripslashes(check_html($url_title, "nohtml"));
    $email = stripslashes(check_html($email, "nohtml"));
    $score = intval($score);
    $cover = stripslashes(check_html($cover, "nohtml"));
    $url = stripslashes(check_html($url, "nohtml"));
    $url_title = stripslashes(check_html($url_title, "nohtml"));
    $hits = intval($hits);
    $id = intval($id);
    $keywords = stripslashes($keywords);
    OpenTable();
    echo "<form method=\"post\" action=\"modules.php?name=$module_name\">";

    if ($title == "") {
       $error = 1;
   echo ""._INVALIDTITLE."<br>";
    }
    if ($text == "") {
       $error = 1;
   echo ""._INVALIDTEXT."<br>";
    }
    if (($score < 0) || ($score > 10)) {
   $error = 1;
   echo ""._INVALIDSCORE."<br>";
    }
    if (($hits < 0) && ($id != 0)) {
   $error = 1;
   echo ""._INVALIDHITS."<br>";
    }
    if ($reviewer == "" || $email == "") {
   $error = 1;
   echo ""._CHECKNAME."<br>";
    } else if ($reviewer != "" && $email != "")
   if (!(eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,3}$",$email))) {
       $error = 1;
       /* eregi checks for a valid email! works nicely for me! */
       echo ""._INVALIDEMAIL."<br>";
   }
   if (($url_title != "" && $url =="") || ($url_title == "" && $url != "")) {
       $error = 1;
       echo ""._INVALIDLINK."<br>";
   } else if (($url != "") && (!(eregi('(^http[s]*:[/]+)(.*)', $url))))
       $url = "http://" . $url;
       /* If the user ommited the http, this nifty eregi will add it */
   if ($error == 1)
       echo "<br>"._GOBACK."";
   else
   {
   if ($date == "")
       $date = date("Y-m-d", time());
       $year2 = substr($date,0,4);
       $month = substr($date,5,2);
       $day = substr($date,8,2);
       $fdate = date("F jS Y",mktime (0,0,0,$month,$day,$year2));
           echo "<table border=\"0\" width=\"100%\"><tr><td colspan=\"2\">";
       echo "<p><font class=\"title\"><i><b>$title</b></i></font><br>";
       echo "<blockquote><p>";
       if ($cover != "")
          echo "<img src=\"images/reviews/$cover\" align=\"right\" border=\"1\" vspace=\"2\" alt=\"\">";
       echo "$text<p>";
      $row = $db->sql_fetchrow($db->sql_query("SELECT * FROM ".$prefix."_jreviews_categories WHERE id='".intval($category)."'"));
       echo "<b>Keywords:</b> $keywords<br>";
       echo "<b>Category</b> ".$row["name"]."<br>";      
       echo "<b>"._ADDED."</b> $fdate<br>";
       if ($multilingual == 1) {
      echo "<b>"._LANGUAGE."</b> $rlanguage<br>";
       }
       echo "<b>"._REVIEWER."</b> <a href=\"mailto:$email\">$reviewer</a><br>";
       echo "<b>"._SCORE."</b> ";
       display_score($score);
       if ($url != "")
      echo "<br><b>"._RELATEDLINK.":</b> <a href=\"$url\" target=\"new\">$url_title</a>";
          $id = intval($id);
       if ($id != 0) {
      echo "<br><b>"._REVIEWID.":</b> $id<br>";
      echo "<b>"._HITS.":</b> $hits<br>";
       }
       echo "</font></blockquote>";
       echo "</td></tr></table>";
       $text = urlencode($text);
       echo "<p><i>"._LOOKSRIGHT."</i> ";
       echo "<input type=\"hidden\" name=\"id\" value=$id>
        <input type=\"hidden\" name=\"hits\" value=\"$hits\">
        <input type=\"hidden\" name=\"rop\" value=send_review>
        <input type=\"hidden\" name=\"date\" value=\"$date\">
        <input type=\"hidden\" name=\"title\" value=\"$title\">
        <input type=\"hidden\" name=\"text\" value=\"$text\">
        <input type=\"hidden\" name=\"category\" value=\"$category\">
        <input type=\"hidden\" name=\"reviewer\" value=\"$reviewer\">
        <input type=\"hidden\" name=\"email\" value=\"$email\">
        <input type=\"hidden\" name=\"score\" value=\"$score\">
        <input type=\"hidden\" name=\"url\" value=\"$url\">
        <input type=\"hidden\" name=\"url_title\" value=\"$url_title\">
        <input type=\"hidden\" name=\"keywords\" value=\"$keywords\">
        <input type=\"hidden\" name=\"cover\" value=\"$cover\">";
        echo "<input type=\"hidden\" name=\"rlanguage\" value=\"$rlanguage\">";
      echo "<input type=\"submit\" name=\"rop\" value=\""._YES."\"> <input type=\"button\" onClick=\"history.go(-1)\" value=\""._NO."\">";
          $id = intval($id);
       if($id != 0)
          $word = ""._RMODIFIED."";
       else
          $word = ""._RADDED."";
       if(is_admin($admin))
          echo "<br><br><b>"._NOTE."</b> "._ADMINLOGGED." $word.";
   }
    CloseTable();
}


Last edited by rogue3 on Sun Sep 13, 2009 6:58 am; edited 1 time in total 
View user's profile Send private message
Palbin
Site Admin



Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania

PostPosted: Fri Sep 11, 2009 3:42 pm Reply with quote

You need to add $keywords to where ever the function is called. It may not have the smae variable names.

Code:


PreviewReview($date, $title, $text, $reviewer, $email, $score, $cover, $url, $url_title, $hits, $id, $rlanguage, $category, $keywords);

_________________
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan. 
View user's profile Send private message
Palbin







PostPosted: Fri Sep 11, 2009 3:43 pm Reply with quote

Also when you "view source" on the preview page can you see the correct values in the hidden input?
 
rogue3







PostPosted: Fri Sep 11, 2009 4:00 pm Reply with quote

No, in the source code it comes up like this:

<input type="hidden" name="keywords" value="">

I must be missing something somewhere!
 
rogue3







PostPosted: Fri Sep 11, 2009 4:05 pm Reply with quote

This is what I have in the functionWriteReview pertaining to the keywords entry:

Code:
    }

    echo "
    <i>"._CHECKREVIEW."</i><br><br>
    <b>"._KEYWORDS."</b><br>
    <input type=\"text\" name=\"keywords\" size=\"70\" maxlength=\"200\"><br>
    <i>"._KEYWORDSHELP."</i><br><br>
    <b>"._YOURNAME.":</b><br>";
    if (is_user($user)) {


Here is my entire table for the reviews:

Image
 
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Fri Sep 11, 2009 8:39 pm Reply with quote

rogue3, you need to see Palbin's post again... if you are expecting that field to be coming from the POST and not the DB, you have to pass that value into the function or declare it as a global inside the function and remove from the parameter list.

Palbin wrote:
You need to add $keywords to where ever the function is called. It may not have the smae variable names.

Code:


PreviewReview($date, $title, $text, $reviewer, $email, $score, $cover, $url, $url_title, $hits, $id, $rlanguage, $category, $keywords);

_________________
Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
rogue3







PostPosted: Sat Sep 12, 2009 6:12 am Reply with quote

OK, my apologies. I'm not the most adept at writing php code so I'm not entirely sure what you mean. I tried to set it up just like one of the other fields. Why would that value need to be declared as a global when none of the other ones were?

I must be missing something. Again, sorry... I'm learning!
 
Palbin







PostPosted: Sat Sep 12, 2009 11:41 am Reply with quote

OK. There is a spot that look like this (note the FUNCTION)

Code:


function PreviewReview($date, $title, $text, $reviewer, $email, $score, $cover, $url, $url_title, $hits, $id, $rlanguage, $category, $keywords);
{
..............
}

Which you fixed already. This only defines the function it does not call the function. It is probably called in the index (not always).

So look for something like this (no FUNCTION):

Code:


PreviewReview($date, $title, $text, $reviewer, $email, $score, $cover, $url, $url_title, $hits, $id, $rlanguage, $category, $keywords);


You will need to find this and add $keywords to it like you did the function. This is what actually executes the function that was defined previously.
If you are using notepad++ or something to edit your files do a search of the files of occurrences of "PreviewReview".
 
rogue3







PostPosted: Sat Sep 12, 2009 2:49 pm Reply with quote

Bingo! Spot on...that's the tip I needed. There were two instances down in the switches that had them (preview and send). I added it to both of those and now it works like a charm.

Thanks so much!

Consider this one solved.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©