Jump to content

include files and use them?


optikalefx

Recommended Posts

so. ive got this complicated part of a php file.  does some sql stuff, and some other stuff.

 

basically i connect to the database, and run a query, then the while($row = mysql_fetch_array($sql)) all the way to the final echo are a remote file.

 

that is because ill be using tha part on several pages, and just want to attach that script..

 

include doenst work.

put doest work.

 

and yes its over 2 diffrent domains, the file is on a different domain. any ideas?

Link to comment
https://forums.phpfreaks.com/topic/63681-include-files-and-use-them/
Share on other sites

this is the website code

<html>
<body bgcolor="white">
<?php
$con = mysql_connect("xxxx","xxxx","xxxx"); 
mysql_select_db("update1", $con);
$sql = mysql_query("SELECT value FROM JohnRobberts WHERE fname='service'");
include 'http://www.4tenproductions.com/pagegen.php';
?>
</body></html>

 

 

and i want this is pagegen that i want to be used right after the sql statement:

while($row = mysql_fetch_array($sql))
{
$string = $row['value'];
}
  //create tag heading
$patterns[0] = '/<heading>/';
$patterns[1] = '/<end heading>/';
$replacements[1] = '<span id=head>';
$replacements[0] = '</span>';

$string = preg_replace($patterns, $replacements, $string);


function getImage($img)
{
    $query = "SELECT pic FROM pics WHERE num ='$img'";
$result = mysql_query($query);
    if(mysql_num_rows($result) == 1)
    {
        $row = mysql_fetch_assoc($result);
        return '<img src="http://www.4tenproductions.com/ir/uploadedfiles2/' . $row['pic'] . '">';
    }
}

$final = preg_replace('/<include picture# ([0-9]+)>/ise', "getImage($1)", $string);
echo $final;

 

 

basically im using that pagegen.php over and over again,the only thing thats chainging is the query thats run.

but include ''; wont work

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.