Jump to content

Capture queries to use within current website?


HHawk

Recommended Posts

Hi there,

I seem to have a problem with my PHP scripting;
For example I am using a FAQ-script within my website. Which works outside the website perfectly. But when called within the website, it gives me problems.

Take a look at the website: http://www.directhosting.nl/carpediem/layout.php
From the navigation menu select F.A.Q.

You will be shown the F.A.Q. page (ignore the missing images and stuff, which are not relevant at the moment).
When you click on a category (testcat1) you will be pushed back to the domaincheck.

I know what is causing this, the coding within the layout.php, which I use to place stuff within the website where I want it to show.

Here is the piece of code I use in the layout.php file:

[code]
<?php
if ( isset($_GET['nieuws'])) {include('nieuws.php'); }
else if ( isset($_GET['webwereld'])) {include('webwereld.php'); }
else if ( isset($_GET['binnenland'])) {include('binnenland.php'); }
else if ( isset($_GET['buitenland'])) {include('buitenland.php'); }
else {include('domeinnaamcheck.php');}
?>
[/code]

This is a partion of the code, but you will get the idea.

When clicking on a link from the F.A.Q. it tries to load;

[code]
layout.php?q=cat-view&category=testcat1
[/code]
(for categories)

or

[code]
layout.php?q=detail&id=1
[/code]
(for item specific information)

Of course it should use the index.php file located in the FAQ directory for this.

I understand you have to capture the query string and use it, but the problem (since I do not know much about PHP) is I don't know how!

I think I have found the 2 queries which are used here:

[code]
<a href="?q=cat-view&amp;category=<? echo"$record->category";?>"><? echo "$record->category";?></a> <font class="small">(<? echo $numentry[0]; ?>)
[/code]
(for categories)

and

[code]
<a href="?q=detail&amp;id=<? echo"$record->id";?>"><? echo "$record->title"; ?>
[/code]
(for item specific information)

Any advice on how to use these queries correctly with my website?

Thanks in advance.
Link to comment
Share on other sites

Are you using layout.php for all your pages and just including all the other pages in it???
From what i am seeing it looks like you have to add another parameter to your link to keep it at the FAQ page.
[code]<a href="layout.php?faq=yes&q=cat-view&category=<? echo"$record->category";?>"><? echo "$record->category";?></a> <font class="small">(<? echo $numentry[0]; ?>)[/code]

Ray
Link to comment
Share on other sites

[quote author=craygo link=topic=119387.msg488859#msg488859 date=1166622173]
Are you using layout.php for all your pages and just including all the other pages in it???
From what i am seeing it looks like you have to add another parameter to your link to keep it at the FAQ page.
[code]<a href="layout.php?faq=yes&q=cat-view&category=<? echo"$record->category";?>"><? echo "$record->category";?></a> <font class="small">(<? echo $numentry[0]; ?>)[/code]

Ray
[/quote]

I am including all the other pages, so it displays where I want it to.
And what you are saying does not work unfortunately; cause it already goes to layout.php. :(

Then it tries to open:
http://www.directhosting.nl/carpediem/layout.php?q=cat-view&category=testcat1

Cause it cannot find the link in the layout.php

I am having problems explaining what's the problem.
Link to comment
Share on other sites

I will try to explain a bit better;

Every link from the navigation area opens in the middle (thanks to $_GET command).
Except with this FAQ script which tries to open a link which is not stated in code in the layout.php file.

I just want it to open normally within my current website.
It now tries to open a link which is not defined so it opens "domeinnaamcheck.php" instead.

So is there a way to enter the query in the layout.php so it opens like I want it to?
For example: else if ( isset($_GET['?faq=yes&q=cat-view&category=<? '])) {include('/faq/index.php'); }

Or something like that?
Link to comment
Share on other sites

OK i see your issue. I put this in the address bar
http://www.directhosting.nl/carpediem/faq/index.php?q=cat-view&category=testcat1

can try this
[code]if(isset($_GET['faq'])) {
$
include('faq/index.php?'.$_SERVER['QUERY_STRING']);
}[/code]

This should include your index page now and also grab the query string from the link

try that

Ray
Link to comment
Share on other sites

Okay I gave it a go.

But now I am getting the following error:

[code]
Fatal error: Call to undefined function: () in /var/www/vhosts/directhosting.nl/httpdocs/carpediem/layout.php on line 29
[/code]

which is what I entered:

[code]
else if(isset($_GET['faq'])) {$include('faq/index.php?'.$_SERVER['QUERY_STRING']);}
[/code]

:S
Link to comment
Share on other sites

Still no succes...

Getting the following error now:

[code]
Warning: main(faq/index.php?faq): failed to open stream: Onbekend bestand of map in /var/www/vhosts/directhosting.nl/httpdocs/carpediem/layout.php on line 47

Warning: main(faq/index.php?faq): failed to open stream: Onbekend bestand of map in /var/www/vhosts/directhosting.nl/httpdocs/carpediem/layout.php on line 47

Warning: main(): Failed opening 'faq/index.php?faq' for inclusion (include_path='.:') in /var/www/vhosts/directhosting.nl/httpdocs/carpediem/layout.php on line 47
[/code]

Link to comment
Share on other sites

Well to be honest, I do not know much about PHP. Sure I can edit stuff I see, but script something myself? No chance. Going to follow several classes in 2007, so I don't have to bother anyone anymore or at least less frequent. I find it annoying to keep asking for help, especially with this.

Anyways the FAQ script, is one of the most simple out there, but I thought it would be easier to integrate it into my current website, so not only the first page is inside the layout, but the rest (next pages from the FAQ) as well.

Here are the pieces of coding, which are relevant (I think):

Navigation part (navigatie.php)
[code]
<table id="navigatie" width="152" height="66" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="3"><img src="images/navigatie_01.jpg" width="152" height="46" alt="" /></td>
  </tr>
  <tr>
    <td width="10" height="100%" background="images/navigatie_02.jpg">&nbsp;</td>
    <td width="128" height="100%" bgcolor="FFFFFF"><table width="128" border="0" cellspacing="0" cellpadding="0">

      <tr>
        <td height="30"><strong>Directhosting</strong></td>
      </tr>
      <tr>
        <td height="15">· <a href="layout.php?nieuws">Nieuws</a></td>
      </tr>
      <tr>
        <td height="15">· <a href="layout.php?directhosting">Over ons</a></td>
      </tr>
      <tr>
        <td height="15">· <a href="layout.php?netwerk">Netwerk</a></td>
      </tr>
      <tr>
        <td height="30"><strong>Hostingpakketten</strong></td>
      </tr>
      <tr>
        <td height="15">· <a href="layout.php?plesk">Plesk</a></td>
      </tr>
      <tr>
        <td height="15">· <a href="layout.php?koper">Koper</a></td>
      </tr>
      <tr>
        <td height="15">· <a href="layout.php?brons">Brons</a></td>
      </tr>
      <tr>
        <td height="15">· <a href="layout.php?zilver">Zilver</a></td>
      </tr>
      <tr>
        <td height="15">· <a href="layout.php?goud">Goud</a></td>
      </tr>
      <tr>
        <td height="15">· <a href="layout.php?platina">Platina</a></td>
      </tr>
      <tr>
        <td height="15">· <a href="layout.php?titanium">Titanium</a></td>
      </tr>
      <tr>
        <td height="13">· <a href="layout.php?overzicht">Overzicht</a></td>
      </tr>
      <tr>
        <td height="13">· <a href="layout.php?pakket">Bestel pakket</a> </td>
      </tr>
      <tr>
        <td height="30"><strong>Domeinnamen</strong></td>
      </tr>

      <tr>
        <td height="15">· <a href="layout.php?algemeen">Algemeen</a></td>
      </tr>
      <tr>
        <td height="15">· <a href="layout.php?prijzen">Prijzen</a></td>
      </tr>
      <tr>
        <td height="15">· <a href="layout.php?formulieren">Formulieren .NL</a> </td>
      </tr>
      <tr>
        <td height="15">· <a href="layout.php?check">Domeinnaamcheck</a></td>
      </tr>
      <tr>
        <td height="15">· <a href="layout.php?domeinnaam">Bestel domeinnaam </a></td>
      </tr>
      <tr>
        <td height="30"><strong>Dedicated Servers</strong> </td>
      </tr>
      <tr>
        <td height="15">· <a href="layout.php?informatie">Informatie</a></td>
      </tr>
      <tr>
        <td height="15">· <a href="layout.php?prijsoverzicht">Prijsoverzicht</a></td>
      </tr>
      <tr>
        <td height="15">· <a href="layout.php?server">Bestel server</a> </td>
      </tr>
      <tr>
        <td height="30"><strong>Overigen</strong></td>
      </tr>
      <tr>
        <td height="15">· <a href="layout.php?faq">F.A.Q.</a></td>
      </tr>
      <tr>
        <td height="15">· <a href="layout.php?abuse">Abuse policy</a></td>
      </tr>
      <tr>
        <td height="15">· <a href="layout.php?spam">Anti-spam policy</a></td>
      </tr>
      <tr>
        <td height="15">· <a href="layout.php?contact">Contactgegevens</a></td>
      </tr>
      <tr>
        <td height="15">· <a href="layout.php?voorwaarden">Voorwaarden</a></td>
      </tr>
      <tr>
        <td height="15">· <a href="layout.php?referenties">Referenties</a></td>
      </tr>
      <tr>
        <td height="5">&nbsp;</td>
      </tr>
    </table>      </td>
    <td width="14" height="100%" background="images/navigatie_04.jpg">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="3"><img src="images/navigatie_05.jpg" width="152" height="18" alt="" /></td>
  </tr>
</table>
[/code]

The layout part (layout.php)
[code]
<?php
setlocale (LC_ALL, 'nl_NL');
?>
<html>
<head>
<title>Directhosting // www.directhosting.nl</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="main.css" />
</head>
<body>

<table width="1024" height="360" border="0" align="center" cellpadding="0" cellspacing="0" id="layout">
<tr>
<td height="118" colspan="5"><?php include("header.php"); ?></td>
</tr>
<tr>
<td height="42" colspan="5"><?php include("tspacer.php"); ?></td>
</tr>
<tr>
<td colspan="5">
<img src="images/layout_03.jpg" width="1024" height="19" alt=""></td>
</tr>
<tr>
<td width="20" height="100%" background="images/layout_04.jpg">&nbsp;</td>
<td width="152" valign="top" bgcolor="217fbd"><?php include("navigatie.php"); ?></td>
<td width="538" valign="top" bgcolor="217fbd">
<?php
if ( isset($_GET['nieuws'])) {include('nieuws.php'); }
else if ( isset($_GET['directhosting'])) {include('overons.php'); }
else if ( isset($_GET['netwerk'])) {include('netwerk.php'); }
else if ( isset($_GET['overzicht'])) {include('overzicht.php'); }
else if ( isset($_GET['koper'])) {include('koper.php'); }
else if ( isset($_GET['brons'])) {include('brons.php'); }
else if ( isset($_GET['zilver'])) {include('zilver.php'); }
else if ( isset($_GET['goud'])) {include('goud.php'); }
else if ( isset($_GET['platina'])) {include('platina.php'); }
else if ( isset($_GET['titanium'])) {include('titanium.php'); }
else if ( isset($_GET['pakket'])) {include('pakket.php'); }
else if ( isset($_GET['algemeen'])) {include('algemeen.php'); }
else if ( isset($_GET['prijzen'])) {include('prijzen.php'); }
else if ( isset($_GET['formulieren'])) {include('formulieren.php'); }
else if ( isset($_GET['check'])) {include('domeinnaamcheck.php'); }
else if ( isset($_GET['domeinnaam'])) {include('domeinnaam.php'); }
else if ( isset($_GET['informatie'])) {include('informatie.php'); }
else if ( isset($_GET['prijsoverzicht'])) {include('prijsoverzicht.php'); }
else if ( isset($_GET['server'])) {include('server.php'); }
else if ( isset($_GET['faq'])) {include('faq/index.php'); }
else if ( isset($_GET['abuse'])) {include('abuse.php'); }
else if ( isset($_GET['spam'])) {include('spam.php'); }
else if ( isset($_GET['contact'])) {include('contact.php'); }
else if ( isset($_GET['voorwaarden'])) {include('voorwaarden.php'); }
else if ( isset($_GET['referenties'])) {include('referenties.php'); }
else if ( isset($_GET['nieuwsalgemeen'])) {include('nalgemeen.php'); }
else if ( isset($_GET['nieuwsnetwerk'])) {include('nnetwerk.php'); }
else if ( isset($_GET['nieuwsarchief'])) {include('archief.php'); }
else if ( isset($_GET['acties'])) {include('actie.php'); }
else if ( isset($_GET['snelheid'])) {include('snelheid.php'); }
else if ( isset($_GET['plesk'])) {include('plesk.php'); }
else if ( isset($_GET['virusmelding'])) {include('virusmeldingen.php'); }
else if ( isset($_GET['tweakers'])) {include('tweakers.php'); }
else if ( isset($_GET['webwereld'])) {include('webwereld.php'); }
else if ( isset($_GET['binnenland'])) {include('binnenland.php'); }
else if ( isset($_GET['buitenland'])) {include('buitenland.php'); }
else {include('domeinnaamcheck.php');}
?>

</td>
<td width="294" valign="top" bgcolor="217fbd">
<?php include("acties.php"); ?>
<?php include("partners.php"); ?></td>
<td width="20" height="100%" background="images/layout_08.jpg">&nbsp;</td>
</tr>
<tr>
<td colspan="5">
<img src="images/layout_09.jpg" width="1024" height="12" alt=""></td>
</tr>
<tr>
<td height="42" colspan="5"><?php include("bspacer.php"); ?></td>
</tr>
<tr>
<td height="61" colspan="5"><?php include("footer.php"); ?></td>
</tr>
</table>

</body>
</html>
[/code]

And as for the index.php for the FAQ (which is located in the faq directory):
[code]
<?

include ("config.php");

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>FAQbar</title>

<meta name="title" content="FAQbar" />
<meta name="description" content="" />
<meta name="keywords" content="keywords, go, here" />
<meta name="owner" content="your e-mail" />
<meta name="author" content="FAQbar" />
<meta http-equiv="Distribution" content="Global" />
<meta http-equiv="Copyright" content="your website" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="content-language" content="English" />
<meta http-equiv="vw96.object-type" content="Personal" />
<meta name="rating" content="General" />
<meta name="robots" content="index, follow" />
<meta name="revisit-after" content="2" />
<meta http-equiv="Content-type" content="text/html; charset=ISO-8859-1" />

<link rel="stylesheet" type="text/css" href="stylesheet.css" />
<link rel="alternate" type="application/rss+xml" title="FAQbar RSS" href="rss.php" />

</head>

<body>

<div id="container">

<div id="header" align="right">
<div id="menu">
<a href="layout.php?terug">terug</a>
<a href="faq/index.php?q=add">submit a question</a>
<a href="faq/admin/">admin</a><p></p>
<form action="faq/index.php?q=search" method="post">
<input type="text" name="searchstring" size="20" />&nbsp;  <button type="submit" name="submit" value="search">Zoeken</button></form>
</div>
</div>

<div id="content">
<!-- CONTENT HERE -->
<p></p>


<?

$content =       "pages/$q.php";

if (strlen($q)==0)

{
        include("pages/home.php");
        }
else
{
if (file_exists($content)) {
        include("pages/$q.php");
        }
        else
        {
        echo "page not found";
        }

}

?>

<p></p>

</div>


<div id="footer">
<p></p>
</div>

</div>
<a href="http://validator.w3.org/check?uri=referer" target="_blank"><img src="layout/buttons/w3cxhtml.gif" alt="xhtml valid" title="xhtml valid" border="0" /></a> <a href="http://jigsaw.w3.org/css-validator/" target="_blank"><img src="layout/buttons/w3ccss.gif" alt="css" title="css" border="0" /></a> <a href="rss.php"><img src="layout/buttons/rss.gif" alt="rss feed" title="rss feed" border="0" /></a>
<a href="http://dev.localhost.be/"><img src="layout/buttons/faqbar.gif" alt="FAQbar powered" title="FAQbar powered" border="0" /></a>
<p></p>
<? $adminmailview = ereg_replace('@', ' [ AT ] ', $adminmail); ?>
problem? mail to <a href="mailto:<? echo"$adminmailview";?>"><? echo"$adminmailview";?></a>

</body>
</html>


<?
mysql_close();
?>
[/code]

I think these are the main ones. If you need more, don't hesitate to ask. I am already someone is trying to help me to pin down this problem...

/edit

Oops almost forgot, I don't know if these are important, but I think they are. Cause of the queries?
They are located in faq/pages/ directory:

cat-view.php
[code]
<a href="?q=home">Home</a> : <? echo "$category";?>
<p></p>

<ul>
<?
$sql = "SELECT * FROM faqbar_content WHERE category='$category' AND status='online' ORDER BY title ASC";
$result = mysql_query($sql);
while ($record = mysql_fetch_object($result)) {

$question = nl2br($record->description);
$answer = nl2br($record->answer);
?>


<li> <a href="?q=detail&amp;id=<? echo"$record->id";?>"><? echo "$record->title"; ?></a></li>

<?
}
?>
</ul>
[/code]

and

home.php
[code]
<ul>

<?
$sql = "SELECT DISTINCT category FROM faqbar_content ORDER BY category ASC";
$result = mysql_query($sql);
while ($record = mysql_fetch_object($result)) {
$query = "SELECT COUNT(*) FROM faqbar_content WHERE category='$record->category' AND status='online'";
$numentries = mysql_query($query) or die("Select Failed!");
$numentry = mysql_fetch_array($numentries);
?>


<li><a href="?q=cat-view&amp;category=<? echo"$record->category";?>"><? echo "$record->category";?></a> <font class="small">(<? echo $numentry[0]; ?>)</font><p></p></li>

<?
}
?>
</ul>
[/code]
Link to comment
Share on other sites

From what I see it will be a problem with your paths. That faqbar script is looking for everything in its own folder which is faq. But the page is running from a folder below that. So you would have to change the paths in the faq pages to fit your needs. I am trying to recreate your problem here, give me a few.

Ray
Link to comment
Share on other sites

I am not sure if you want this but I had to update almost all the pages in that faq script. I have it working now being included in a page. I included a zip file. maybe change the name of your current faq folder and unzip this one. You may have to add one more check for your includes on your layout.php
[code]if(isset($_GET['admin'])){ include('faq/admin/index.php'); }[/code]

Let me know how you make out

Ray

[attachment deleted by admin]
Link to comment
Share on other sites

Weird... I made a backup of my current FAQ.
Next I unpacked your zip to a local folder.

Transfered everything, edited the config.php, but I am getting the following error;

[code]
Warning: mysql_connect(): Access denied for user 'apache'@'localhost' (using password: NO) in /var/www/vhosts/directhosting.nl/httpdocs/carpediem/config.php on line 45

Warning: mysql_select_db(): Access denied for user 'apache'@'localhost' (using password: NO) in /var/www/vhosts/directhosting.nl/httpdocs/carpediem/config.php on line 46

Warning: mysql_select_db(): A link to the server could not be established in /var/www/vhosts/directhosting.nl/httpdocs/carpediem/config.php on line 46
Unable to select database
[/code]

But the config file seems okay to me...

/edit

Nevermind, something is wrong I guess, cause it's happening with the backup as well...
...looking into it.
Link to comment
Share on other sites

Uhm... Okay the error seems permanent for some reason.
I deleted the old MySQL database, then created a new one.
Copied everything to the faq dir (from the zip), edited the config.php correctly to the new values, but I still get the same error mentioned above. :S

I appreciate your help, but it looks like this will never work. :S
If you know of a better FAQ or Knowledgebase, which will work better within my website, please tell. It does not have to be very special. Just a Q & A which uses the MySQL db and the ability to add and delete stuff. That's all. That's the main reason I picked this FAQ for starters. I thought it would be "easy" to integrate within my website... :(
Link to comment
Share on other sites

You could create it yourself if you want. Just a bunch of forms and such. In order for that script to work that I gave you, it has to be setup like you had it. It will no longer work on it's own and will not be able to find the config file. Which is how it connects to the database.

I don't want to intrude with you or anything but if you gave me temp ftp access I would be glad to get it working for you. But that is entirely up to you. I use rapidftp so I will just be editing files and nothing more.

Ray
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.