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
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

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.