str_replace help needed

Reply

Join Date: Jun 2007
Posts: 1,227
Reputation: kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about 
Solved Threads: 167
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Nearly a Posting Virtuoso
 
0
  #11
30 Days Ago
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.
Google is your friend.

Use [code] tags.

If you have found a solution to your problem, please mark the thread as SOLVED.
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,227
Reputation: kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about 
Solved Threads: 167
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Nearly a Posting Virtuoso
 
0
  #12
30 Days Ago
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.
Google is your friend.

Use [code] tags.

If you have found a solution to your problem, please mark the thread as SOLVED.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 525
Reputation: network18 is an unknown quantity at this point 
Solved Threads: 61
network18 network18 is offline Offline
Posting Pro
 
0
  #13
30 Days Ago
can you post the part of your code here, we will modify it
"The discipline of writing something down is the first step towards making it happen."

follow me on twitter
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 15
Reputation: alagirinetaxis is an unknown quantity at this point 
Solved Threads: 3
alagirinetaxis alagirinetaxis is offline Offline
Newbie Poster
 
0
  #14
30 Days Ago
  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. ?>
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 15
Reputation: alagirinetaxis is an unknown quantity at this point 
Solved Threads: 3
alagirinetaxis alagirinetaxis is offline Offline
Newbie Poster
 
0
  #15
30 Days Ago
  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. ?>
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 24
Reputation: liamfriel is an unknown quantity at this point 
Solved Threads: 1
liamfriel's Avatar
liamfriel liamfriel is offline Offline
Newbie Poster
 
0
  #16
30 Days Ago
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; 30 Days Ago at 8:33 am.
They throw us away like yesterdays jam - Maurice Mossley

Please - rep if someone helps you, it can't be traded for stuff, but it's nice.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 9
Reputation: Zack_G is an unknown quantity at this point 
Solved Threads: 0
Zack_G Zack_G is offline Offline
Newbie Poster
 
0
  #17
30 Days Ago
Hi Guys,

Thank's for all your help so far.

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

index.php
  1. include('includes/global.php');
  2. DisplayIndex();

global.php
  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; 30 Days Ago at 9:26 am.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 36
Reputation: Froger93 is an unknown quantity at this point 
Solved Threads: 4
Froger93 Froger93 is offline Offline
Light Poster
 
0
  #18
30 Days Ago
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...

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

As an example.

As I said I might have missed something.
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 9
Reputation: Zack_G is an unknown quantity at this point 
Solved Threads: 0
Zack_G Zack_G is offline Offline
Newbie Poster
 
0
  #19
30 Days Ago
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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 24
Reputation: liamfriel is an unknown quantity at this point 
Solved Threads: 1
liamfriel's Avatar
liamfriel liamfriel is offline Offline
Newbie Poster
 
0
  #20
30 Days Ago
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; 30 Days Ago at 1:40 pm.
They throw us away like yesterdays jam - Maurice Mossley

Please - rep if someone helps you, it can't be traded for stuff, but it's nice.
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC