PDA

View Full Version : Help with include



Danii
October 26th, 2004, 03:55 PM
I have a file named sites.php and another file named queries.php

in the sites.php file I've written:
include 'queries.php?qtype=show_sites';

and in the queries.php file:
$type = $_GET['qtype'];
//some code
return $query;

But when I run the sites.php script it says it can't find the file queries.php?qtype=show_sites.

So basically I want to use include so that it can return me a variable, but I also want that file to recieve a variable. How do I do this?

Jubba
October 26th, 2004, 06:24 PM
tryin including the entire path to the file you want to include. For some reason i couldn' get

query.php?qtype=news

to work, but

www.mydomain.com/test/query.php?qtype=news

did work. try that.

Danii
October 27th, 2004, 09:02 AM
Yea it worked but it wont return anything

in my queries.php there this code:
$type = $_GET['qtype'];

switch($type) {
case "sajter_show":
$query = "SOME SQL";
break;
}

echo $query //ouputs the sql
return $query;

------------------------------

sites.php;

include 'http://mysite.com/queries.php?qtype=sajter_show';

echo $query; //outputs nothing????

Why wont it output the sql???

meewsh
July 13th, 2005, 06:25 PM
When I try to look at the example sites.php , sites.as and sites.swf I get the following error
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:\sites.php on line 14
&n=

Can anyone help? I looked up php.net and I saw that the function is okay. I am using the latest version of php.


<?php

//require($_SERVER["DOCUMENT_ROOT"]."/config/db_config.php");
//$connection = mysql_connect($db_host, $db_user, $db_password) or die("error connecting");
//mysql_select_db($db_name, $connection);

//mysql_pconnect ("localhost","username","password");
//mysql_select_db ("sites;");

$link = mysql_connect("localhost", "username", "password");
mysql_select_db("sites", $link);

$qResult = mysql_query ("SELECT * FROM sites ORDER BY id ASC", $link);
$nRows = mysql_num_rows($qResult);
$rString ="&n=".$nRows;

for ($i=0; $i< $nRows; $i++){
$row = mysql_fetch_array($qResult);
$rString .="&amp;id".$i."=".$row['id']."&"."&title".$i."=".$row['title']."&"."&link".$i."=http://".$row['link']."&";
}
echo $rString."&";

?>