The script I've got is not sending variables to embeded proceedures. I don't know why it is no longer working. I have a feeling it is due to changes in PHP syntax.
When I click on one of the options from the database, it stays on the same page and doesn't move on to the link page. The link string however goes show up in the browser, but that's it.
Thanks in advance if you can let me know what needs to be fixed or changed!
HERE IS THE CODE:
<?php
include ("conf.php"
;
include ("func_set.php"
;
if ( isset($qid) ) {
// Display question and answer
connex();
if ($topmenu == 1 and isset($catid))
whereareu($catid);
elseif (isset($frommosrec) )
print "<p align=\"center\"><a href=\"$faqindex\">Home</a> > Most Recent Questions</p>";
elseif (isset($frommospop))
print "<p align=\"center\"><a href=\"$faqindex\">Home</a> > Most Popular Questions</p>";
else
print "<p align=\"center\"><a href=\"$faqindex\">Home</a> > <a href=\"$faqindex?runsearch=start\">Search FAQ</a></p>";
$query = "Select question, answer, viewed FROM faq_qandas WHERE qid = $qid";
$qinfo = mysql_query( $query, $link ) or die("Error pulling subcat list from database: ".mysql_error());
$question = mysql_fetch_array( $qinfo );
// Strip slashes, then change hard returns to <BR> and spaces to if there are no <BR> or paragraph tags already in place
$thisquestion = $question[question];
if (substr_count($thisquestion, "<p"
== 0 && substr_count($thisquestion, "<BR>"
== 0)
$thisquestion = nl2br($thisquestion);
$thisquestion = str_replace(" ", " ", $thisquestion);
$thisquestion = stripslashes($thisquestion);
$thisanswer = $question[answer];
if (substr_count($thisanswer, "<p"
== 0 && substr_count($thisanswer, "<BR>"
== 0 && substr_count($thisanswer, "<ul"
== 0)
$thisanswer = nl2br($thisanswer);
$thisanswer = str_replace(" ", " ", $thisanswer);
$thisanswer = stripslashes($thisanswer);
print "<P><strong>$thisquestion</strong></P>";
print "<blockquote>$thisanswer</blockquote>";
$newview = $question[viewed] + 1;
$query = "UPDATE faq_qandas SET viewed = $newview WHERE qid = $qid";
$qinfo = mysql_query( $query, $link ) or die("Error updating view count: ".mysql_error());
footerlinks();
}
elseif ( isset($submitq) ) { // Question submission page
// check for form submission. If none, show form
if (!isset($question)) {
// include ("header.php"
;
connex();
if ($topmenu == 1 and isset($catid))
whereareu($catid);
else
print "<p align=\"center\"><a href=\"$faqindex\">Home</a> > <a href=\"$faqindex?submitq=yes\">Submit New Question</a></p>";
$submitterip = $REMOTE_ADDR;
print "
<p align=\"center\"><strong>Submit New Question</strong></p>
<form name=\"form1\" method=\"post\" action=\"$_SERVER[PHP_SELF]?page=questions\">
<input type=\"hidden\" name=\"submitq\" value=\"yes\">
<table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\" align=\"center\">
<tr valign=\"top\">
<td><b>New Question<BR>(maximum length 255)</b></td>
<td>
<textarea name=\"question\" rows=\"3\" cols=\"30\" onkeyup=\"this.value = this.value.slice(0, 255)\"></textarea>
</td>
</tr>
<tr valign=\"top\">
<td><b>Your Name</b></td>
<td>
<input type=\"text\" name=\"submittername\" size=\"30\" maxlength=\"100\">
</td>
</tr>
<tr valign=\"top\">
<td><b>Your Email (not required)</b></td>
<td>
<input type=\"text\" name=\"submitteremail\" size=\"30\" maxlength=\"255\">
</td>
</tr>
<tr valign=\"top\">
<td><b>Your IP (recorded for security)</b></td>
<td>$submitterip<input type=\"hidden\" name=\"submitterip\" size=\"30\" maxlength=\"255\" value=\"$submitterip\"></td>
</tr>
<tr valign=\"top\">
<td><b>Suggested Category</b></td>
<td>
<select name=\"catid\" size=\"5\">";
// For questions being edited, pull the list of currently assigned cats
if (isset($catid)) {
$assignedlist[] = $catid;
}
// otherwise set the assigned cat equal to the category being worked in
else
$assignedlist[] = "";
$maincats = "Select catid, cat FROM faq_cats WHERE maincat = 0 ORDER BY cat";
$cats = mysql_query( $maincats, $link ) or die("Error pulling main category list from database: ".mysql_error());
while ($maincatlist = mysql_fetch_array( $cats )) {
if ( in_array( "$maincatlist[catid]", $assignedlist) )
print "<option value=\"$maincatlist[catid]\" selected>$maincatlist
</option>";
else
print "<option value=\"$maincatlist[catid]\">$maincatlist
</option>";
subcats_qoption($maincatlist[catid], "$maincat", 2, $assignedlist);
}
print "
</select>
</td>
</tr>
<tr valign=\"top\">
<td colspan=\"2\" align=\"center\"><input type=\"submit\" name=\"Submit\" value=\"Submit\"></td>
</tr>
</table>
</form>
";
footerlinks();
}
else {
if ($question == ""
die("You must enter a question to add to the database!"
;
if ($submittername == ""
die("You must enter your name in order to submit a question to the database!"
;
// if question and name have been entered, call add function
usersubmittedquestion($question, $submittername, $submitteremail, $submitterip, $catid);
// include ("header.php"
;
print "<p align=\"center\"><strong>$result</strong></p>";
footerlinks();
}
}
elseif ( isset($catid) ) {
connex();
if ($topmenu == 1)
whereareu($catid);
$query = "SELECT catid, cat, description
FROM faq_cats
WHERE maincat = $catid
ORDER BY cat";
$subcatlist = mysql_query( $query, $link ) or die("Error pulling subcat list from database: ".mysql_error());
$num_rows = mysql_num_rows( $subcatlist );
if ($num_rows > 0) {
print "<dl>";
while ($subcats = mysql_fetch_array( $subcatlist )) {
$cat = stripslashes($subcats
);
print "<dt><a href=\"$faqindex?catid=$subcats[catid]\"><strong>$cat</strong>";
if ($showcounts == 1) {
$query = "SELECT DISTINCT qid
FROM faq_whichcats INNER JOIN faq_cats ON faq_whichcats.catid = faq_cats.catid
WHERE maincat = $subcats[catid]
OR faq_whichcats.catid = $subcats[catid]";
$qlist = mysql_query( $query, $link ) or die("Error pulling question counts from database: ".mysql_error());
$qcount = mysql_num_rows( $qlist );
print " ($qcount)";
}
print "</a></dt>";
if ($usedescripts == 1) {
$catdescription = stripslashes($subcats[description]);
print "<dd>$catdescription</dd>";
}
}
print "</dl>";
}
// Show question list, if any are available
$query = "SELECT faq_qandas.qid, question
FROM faq_qandas INNER JOIN faq_whichcats ON faq_qandas.qid = faq_whichcats.qid
WHERE catid = $catid
ORDER BY question";
$qlist = mysql_query( $query, $link ) or die("Error pulling question list from database: ".mysql_error());
$num_rows = mysql_num_rows( $qlist );
if ($num_rows == 0)
print "<p align=\"center\">There are no questions listed in this category</p>";
else {
print "<p> </p>";
if ($num_rows == 1)
print "<p>There is $num_rows question available in this category.</p>";
else
print "<p>There are $num_rows questions available in this category.</p>";
print "<ul>";
while ($questions = mysql_fetch_array( $qlist )) {
$question = stripslashes($questions[question]);
print "<li> <a href=\"$faqindex?qid=$questions[qid]&catid=$catid\">$question</a></li>";
}
print "</ul>";
}
footerlinks();
}
elseif ( isset($runsearch) ) {
if ($runsearch == "yes"
{ $searchterms = escapeshellcmd($searchterms);
processsearch($searchterms,$limitcat);
}
else {
connex();
print "
<h4 align=\"center\">Search $faqname</h4>
<form name=\"form1\" method=\"post\" action=\"$_SERVER[PHP_SELF]\">
<input type=\"hidden\" name=\"runsearch\" value=\"yes\">
<table width=\"500\" border=\"0\" align=\"center\" cellpadding=\"4\" cellspacing=\"0\">
<tr align=\"left\" valign=\"top\">
<td nowrap><p><strong>Enter Search Terms</strong></p></td>
<td><input name=\"searchterms\" type=\"text\" id=\"searchterms\" size=\"30\" maxlength=\"100\"></td>
</tr>
<tr align=\"left\" valign=\"top\">
<td nowrap><strong>Limit to a specific category?</strong></td>
<td>
<select name=\"limitcat\">
<option value=\"\">-- Search All Categories --</option>
";
$maincats = "Select catid, cat FROM faq_cats WHERE maincat = 0 ORDER BY cat";
$cats = mysql_query( $maincats, $link ) or die("Error pulling category list from database: ".mysql_error());
while ($maincatlist = mysql_fetch_array( $cats )) {
$cat = stripslashes($maincatlist
);
if ($maincatlist[catid] == $maincat)
print "<option value=\"$maincatlist[catid]\" selected>$cat</option>";
else
print "<option value=\"$maincatlist[catid]\">$cat</option>";
subcats_option("$maincatlist[catid]", "$maincat", 2);
}
print "
</select>
</td>
</tr>
<tr>
<td colspan=\"2\" align=\"center\" valign=\"top\">
<input name=\"Submit\" type=\"submit\" id=\"Submit\" value=\"Run My Search\">
</td>
</tr>
</table>
</form>
";
}
footerlinks();
}
else { // Display entry page
$isindex = "Yes";
if (($mospop == 1 && $anypop == "yes"
|| $mosrec == 1)
print "<p style=\"font-family:arial;font-size:9pt;border:#A0A0A0 1px
solid;background-color:#D0D0D0;font-weight:bold;\"> Frequently Asked
Questions</p>";
print "<dl>";
connectToDB();
$query = "SELECT catid, cat, description
FROM faq_cats
WHERE maincat = 0
ORDER BY cat";
$catlist = mysql_query( $query, $link ) or die("Error pulling cat list from database: ".mysql_error());
while ($cat = mysql_fetch_array( $catlist )) {
$thiscat = stripslashes($cat
);
print "<dt><a href=\"$faqindex?catid=$cat[catid]\">$thiscat";
if ($showcounts == 1) {
$query = "SELECT DISTINCT qid
FROM faq_whichcats INNER JOIN faq_cats ON faq_whichcats.catid = faq_cats.catid
WHERE maincat = $cat[catid]
OR faq_whichcats.catid = $cat[catid]";
$qlist = mysql_query( $query, $link ) or die("Error pulling question counts from database: ".mysql_error());
$qcount = mysql_num_rows( $qlist );
print " ($qcount)";
}
print "</a></dt>";
if ($usedescripts == 1) {
$catdescription = stripslashes($cat[description]);
print "<dd>$catdescription</dd>";
}
}
print "</dl>";
footerlinks();
}
?>
Rninja
When I click on one of the options from the database, it stays on the same page and doesn't move on to the link page. The link string however goes show up in the browser, but that's it.
Thanks in advance if you can let me know what needs to be fixed or changed!
HERE IS THE CODE:
<?php
include ("conf.php"
include ("func_set.php"
if ( isset($qid) ) {
// Display question and answer
connex();
if ($topmenu == 1 and isset($catid))
whereareu($catid);
elseif (isset($frommosrec) )
print "<p align=\"center\"><a href=\"$faqindex\">Home</a> > Most Recent Questions</p>";
elseif (isset($frommospop))
print "<p align=\"center\"><a href=\"$faqindex\">Home</a> > Most Popular Questions</p>";
else
print "<p align=\"center\"><a href=\"$faqindex\">Home</a> > <a href=\"$faqindex?runsearch=start\">Search FAQ</a></p>";
$query = "Select question, answer, viewed FROM faq_qandas WHERE qid = $qid";
$qinfo = mysql_query( $query, $link ) or die("Error pulling subcat list from database: ".mysql_error());
$question = mysql_fetch_array( $qinfo );
// Strip slashes, then change hard returns to <BR> and spaces to if there are no <BR> or paragraph tags already in place
$thisquestion = $question[question];
if (substr_count($thisquestion, "<p"
$thisquestion = nl2br($thisquestion);
$thisquestion = str_replace(" ", " ", $thisquestion);
$thisquestion = stripslashes($thisquestion);
$thisanswer = $question[answer];
if (substr_count($thisanswer, "<p"
$thisanswer = nl2br($thisanswer);
$thisanswer = str_replace(" ", " ", $thisanswer);
$thisanswer = stripslashes($thisanswer);
print "<P><strong>$thisquestion</strong></P>";
print "<blockquote>$thisanswer</blockquote>";
$newview = $question[viewed] + 1;
$query = "UPDATE faq_qandas SET viewed = $newview WHERE qid = $qid";
$qinfo = mysql_query( $query, $link ) or die("Error updating view count: ".mysql_error());
footerlinks();
}
elseif ( isset($submitq) ) { // Question submission page
// check for form submission. If none, show form
if (!isset($question)) {
// include ("header.php"
connex();
if ($topmenu == 1 and isset($catid))
whereareu($catid);
else
print "<p align=\"center\"><a href=\"$faqindex\">Home</a> > <a href=\"$faqindex?submitq=yes\">Submit New Question</a></p>";
$submitterip = $REMOTE_ADDR;
print "
<p align=\"center\"><strong>Submit New Question</strong></p>
<form name=\"form1\" method=\"post\" action=\"$_SERVER[PHP_SELF]?page=questions\">
<input type=\"hidden\" name=\"submitq\" value=\"yes\">
<table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\" align=\"center\">
<tr valign=\"top\">
<td><b>New Question<BR>(maximum length 255)</b></td>
<td>
<textarea name=\"question\" rows=\"3\" cols=\"30\" onkeyup=\"this.value = this.value.slice(0, 255)\"></textarea>
</td>
</tr>
<tr valign=\"top\">
<td><b>Your Name</b></td>
<td>
<input type=\"text\" name=\"submittername\" size=\"30\" maxlength=\"100\">
</td>
</tr>
<tr valign=\"top\">
<td><b>Your Email (not required)</b></td>
<td>
<input type=\"text\" name=\"submitteremail\" size=\"30\" maxlength=\"255\">
</td>
</tr>
<tr valign=\"top\">
<td><b>Your IP (recorded for security)</b></td>
<td>$submitterip<input type=\"hidden\" name=\"submitterip\" size=\"30\" maxlength=\"255\" value=\"$submitterip\"></td>
</tr>
<tr valign=\"top\">
<td><b>Suggested Category</b></td>
<td>
<select name=\"catid\" size=\"5\">";
// For questions being edited, pull the list of currently assigned cats
if (isset($catid)) {
$assignedlist[] = $catid;
}
// otherwise set the assigned cat equal to the category being worked in
else
$assignedlist[] = "";
$maincats = "Select catid, cat FROM faq_cats WHERE maincat = 0 ORDER BY cat";
$cats = mysql_query( $maincats, $link ) or die("Error pulling main category list from database: ".mysql_error());
while ($maincatlist = mysql_fetch_array( $cats )) {
if ( in_array( "$maincatlist[catid]", $assignedlist) )
print "<option value=\"$maincatlist[catid]\" selected>$maincatlist
![[cat] [cat] [cat]](/data/assets/smilies/cat.gif)
else
print "<option value=\"$maincatlist[catid]\">$maincatlist
![[cat] [cat] [cat]](/data/assets/smilies/cat.gif)
subcats_qoption($maincatlist[catid], "$maincat", 2, $assignedlist);
}
print "
</select>
</td>
</tr>
<tr valign=\"top\">
<td colspan=\"2\" align=\"center\"><input type=\"submit\" name=\"Submit\" value=\"Submit\"></td>
</tr>
</table>
</form>
";
footerlinks();
}
else {
if ($question == ""
die("You must enter a question to add to the database!"
if ($submittername == ""
die("You must enter your name in order to submit a question to the database!"
// if question and name have been entered, call add function
usersubmittedquestion($question, $submittername, $submitteremail, $submitterip, $catid);
// include ("header.php"
print "<p align=\"center\"><strong>$result</strong></p>";
footerlinks();
}
}
elseif ( isset($catid) ) {
connex();
if ($topmenu == 1)
whereareu($catid);
$query = "SELECT catid, cat, description
FROM faq_cats
WHERE maincat = $catid
ORDER BY cat";
$subcatlist = mysql_query( $query, $link ) or die("Error pulling subcat list from database: ".mysql_error());
$num_rows = mysql_num_rows( $subcatlist );
if ($num_rows > 0) {
print "<dl>";
while ($subcats = mysql_fetch_array( $subcatlist )) {
$cat = stripslashes($subcats
![[cat] [cat] [cat]](/data/assets/smilies/cat.gif)
print "<dt><a href=\"$faqindex?catid=$subcats[catid]\"><strong>$cat</strong>";
if ($showcounts == 1) {
$query = "SELECT DISTINCT qid
FROM faq_whichcats INNER JOIN faq_cats ON faq_whichcats.catid = faq_cats.catid
WHERE maincat = $subcats[catid]
OR faq_whichcats.catid = $subcats[catid]";
$qlist = mysql_query( $query, $link ) or die("Error pulling question counts from database: ".mysql_error());
$qcount = mysql_num_rows( $qlist );
print " ($qcount)";
}
print "</a></dt>";
if ($usedescripts == 1) {
$catdescription = stripslashes($subcats[description]);
print "<dd>$catdescription</dd>";
}
}
print "</dl>";
}
// Show question list, if any are available
$query = "SELECT faq_qandas.qid, question
FROM faq_qandas INNER JOIN faq_whichcats ON faq_qandas.qid = faq_whichcats.qid
WHERE catid = $catid
ORDER BY question";
$qlist = mysql_query( $query, $link ) or die("Error pulling question list from database: ".mysql_error());
$num_rows = mysql_num_rows( $qlist );
if ($num_rows == 0)
print "<p align=\"center\">There are no questions listed in this category</p>";
else {
print "<p> </p>";
if ($num_rows == 1)
print "<p>There is $num_rows question available in this category.</p>";
else
print "<p>There are $num_rows questions available in this category.</p>";
print "<ul>";
while ($questions = mysql_fetch_array( $qlist )) {
$question = stripslashes($questions[question]);
print "<li> <a href=\"$faqindex?qid=$questions[qid]&catid=$catid\">$question</a></li>";
}
print "</ul>";
}
footerlinks();
}
elseif ( isset($runsearch) ) {
if ($runsearch == "yes"
processsearch($searchterms,$limitcat);
}
else {
connex();
print "
<h4 align=\"center\">Search $faqname</h4>
<form name=\"form1\" method=\"post\" action=\"$_SERVER[PHP_SELF]\">
<input type=\"hidden\" name=\"runsearch\" value=\"yes\">
<table width=\"500\" border=\"0\" align=\"center\" cellpadding=\"4\" cellspacing=\"0\">
<tr align=\"left\" valign=\"top\">
<td nowrap><p><strong>Enter Search Terms</strong></p></td>
<td><input name=\"searchterms\" type=\"text\" id=\"searchterms\" size=\"30\" maxlength=\"100\"></td>
</tr>
<tr align=\"left\" valign=\"top\">
<td nowrap><strong>Limit to a specific category?</strong></td>
<td>
<select name=\"limitcat\">
<option value=\"\">-- Search All Categories --</option>
";
$maincats = "Select catid, cat FROM faq_cats WHERE maincat = 0 ORDER BY cat";
$cats = mysql_query( $maincats, $link ) or die("Error pulling category list from database: ".mysql_error());
while ($maincatlist = mysql_fetch_array( $cats )) {
$cat = stripslashes($maincatlist
![[cat] [cat] [cat]](/data/assets/smilies/cat.gif)
if ($maincatlist[catid] == $maincat)
print "<option value=\"$maincatlist[catid]\" selected>$cat</option>";
else
print "<option value=\"$maincatlist[catid]\">$cat</option>";
subcats_option("$maincatlist[catid]", "$maincat", 2);
}
print "
</select>
</td>
</tr>
<tr>
<td colspan=\"2\" align=\"center\" valign=\"top\">
<input name=\"Submit\" type=\"submit\" id=\"Submit\" value=\"Run My Search\">
</td>
</tr>
</table>
</form>
";
}
footerlinks();
}
else { // Display entry page
$isindex = "Yes";
if (($mospop == 1 && $anypop == "yes"
print "<p style=\"font-family:arial;font-size:9pt;border:#A0A0A0 1px
solid;background-color:#D0D0D0;font-weight:bold;\"> Frequently Asked
Questions</p>";
print "<dl>";
connectToDB();
$query = "SELECT catid, cat, description
FROM faq_cats
WHERE maincat = 0
ORDER BY cat";
$catlist = mysql_query( $query, $link ) or die("Error pulling cat list from database: ".mysql_error());
while ($cat = mysql_fetch_array( $catlist )) {
$thiscat = stripslashes($cat
![[cat] [cat] [cat]](/data/assets/smilies/cat.gif)
print "<dt><a href=\"$faqindex?catid=$cat[catid]\">$thiscat";
if ($showcounts == 1) {
$query = "SELECT DISTINCT qid
FROM faq_whichcats INNER JOIN faq_cats ON faq_whichcats.catid = faq_cats.catid
WHERE maincat = $cat[catid]
OR faq_whichcats.catid = $cat[catid]";
$qlist = mysql_query( $query, $link ) or die("Error pulling question counts from database: ".mysql_error());
$qcount = mysql_num_rows( $qlist );
print " ($qcount)";
}
print "</a></dt>";
if ($usedescripts == 1) {
$catdescription = stripslashes($cat[description]);
print "<dd>$catdescription</dd>";
}
}
print "</dl>";
footerlinks();
}
?>
Rninja
