944,110 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1085
  • PHP RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Oct 29th, 2009
0
Re: str_replace help needed
You would need to run the new string through eval to make the includes work.

Use that function with caution though. If you don't use it right there are huge security risks.
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Oct 29th, 2009
0
Re: str_replace help needed
You would need to run the new string through eval to make the includes work.

Use that function with caution though. If you don't use it right there are huge security risks.
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Oct 29th, 2009
0
Re: str_replace help needed
can you post the part of your code here, we will modify it
Reputation Points: 29
Solved Threads: 76
Practically a Master Poster
network18 is offline Offline
616 posts
since Sep 2009
Oct 29th, 2009
0
Re: str_replace help needed
PHP Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. $file_path = "modules/gallery/index.php";
  4.  
  5. include ($file_path);
  6.  
  7. $file_path = str_replace("gallery","enquiry",$file_path);
  8.  
  9. include ($file_path);
  10.  
  11. ?>
Reputation Points: 10
Solved Threads: 3
Newbie Poster
alagirinetaxis is offline Offline
15 posts
since Oct 2009
Oct 29th, 2009
0
Re: str_replace help needed
PHP Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. $file_path = "modules/gallery/index.php";
  4.  
  5. include ($file_path);
  6.  
  7. $file_path = str_replace("gallery","enquiry",$file_path);
  8.  
  9. include ($file_path);
  10.  
  11. ?>
Reputation Points: 10
Solved Threads: 3
Newbie Poster
alagirinetaxis is offline Offline
15 posts
since Oct 2009
Oct 29th, 2009
0
Re: str_replace help needed
Is [GALLERY] inside <?php ?> tags?

I would manually code the include where you want.

One way would to be use authoring software like DW to search and replace [GALLERY] with <?php include("gallery/index.php"); ?>

also kkeith29's idea is a great possibility, but comes with risks.
Last edited by liamfriel; Oct 29th, 2009 at 8:33 am.
Reputation Points: 13
Solved Threads: 13
Junior Poster
liamfriel is offline Offline
101 posts
since Oct 2009
Oct 29th, 2009
0
Re: str_replace help needed
Hi Guys,

Thank's for all your help so far.

Sure. I have 2 files pulling this together so far.

index.php
PHP Syntax (Toggle Plain Text)
  1. include('includes/global.php');
  2. DisplayIndex();

global.php
PHP Syntax (Toggle Plain Text)
  1. function DisplayIndex() {
  2.  
  3. ConnDB();
  4.  
  5. $index = mysql_query("SELECT * FROM pages WHERE url='index' AND page_group='0'")
  6. or die(mysql_error());
  7.  
  8. while($pager = mysql_fetch_array( $index )) {
  9.  
  10.  
  11. include('build.php');
  12. include('_lang.php');
  13. include('seo.php');
  14. include('design/1.php');
  15.  
  16. echo $pager['code'];
  17.  
  18. include('design/2.php');
  19.  
  20. }
  21.  
  22. }

As you can see, the content is stored in a mysql database.

What i would like is that when someone stores somthing like this in the database:

Contact Us
[enquiry]

Or browse view our gallery
[gallery]

They will appear from an includes. $pager['code'] is pulling the content for the page.

Zack.
Last edited by Zack_G; Oct 29th, 2009 at 9:26 am.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Zack_G is offline Offline
9 posts
since Sep 2009
Oct 29th, 2009
0
Re: str_replace help needed
Hmmm, am I missing something as I don't understand why you are doing it that way why not make your path then include it...

php Syntax (Toggle Plain Text)
  1. $path = "includes/" . $pager['code'] . "/index.php";
  2. include( $path );

As an example.

As I said I might have missed something.
Reputation Points: 11
Solved Threads: 6
Junior Poster in Training
Froger93 is offline Offline
74 posts
since Sep 2009
Oct 29th, 2009
0
Re: str_replace help needed
Hi,

Basically a client can login and update the content of there webpage. This content is saved to a mysql database.

Onto the next part, when the mysql database content is pulled and displayed on the actual webpage during a echo i need to be able to scan for tags, for example [enquiry] or [gallery] and include the relevent file for that tag.

Let's say the customer udpates the content of there index page to say "This is my index page. Why not email me using our contact form [enquiry]" then we need to include enquiry.php.

Currently everything works apart from the whole issue with searching and replacing tags with the relevent include file.

Zack.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Zack_G is offline Offline
9 posts
since Sep 2009
Oct 29th, 2009
0
Re: str_replace help needed
This would be very annoying as you would need to stop outputting the database information, place the include(); and then start echoing out the rest.

I would have no idea where to start with something like that.

One idea would be to load both pages into a variable at the start names $enquiry and $gallery and output them that way.
Last edited by liamfriel; Oct 29th, 2009 at 1:40 pm.
Reputation Points: 13
Solved Threads: 13
Junior Poster
liamfriel is offline Offline
101 posts
since Oct 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Validation in Zend Framework Not working in Index Controller
Next Thread in PHP Forum Timeline: Php mysql image scroll script??





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC