Page 1 of 1

PHP

PostPosted: 30. March 2013 22:13
by donz2013
I am converting a html website to codeigniter
I store the page content in a table on mysql
However when it transfers the content to the webpage
it reads the php tags as they are instead of converting them to HTML.

I know Im probably not explaining this very well, for an example
in my code it has:

Code: Select all
 <p><img id="imgborder" src="<?php echo base_url();?>img/stairs.jpg" alt="office stairs"/>


when I check the pages source in my browser the
Code: Select all
<?php echo base_url();?>

...part of the code is still in there instead of converting to html and reading something like http://localhost/sitename/

does anyone know why this is,

Re: PHP

PostPosted: 30. March 2013 23:58
by Altrea
Hi donz2013,

Please start new threads with the words "Hi" or "Hello". A short salutation is an act of politeness. Even if the internet is an virtual area, there is always a human being behind the screen. A polite beginning is the first positive impression you can leave here and helps to get polite answers too. Please keep that in mind if you start a new thread in any community board. Thank you.

donz2013 wrote:I store the page content in a table on mysql
However when it transfers the content to the webpage
it reads the php tags as they are instead of converting them to HTML.

What? I don't understand a word of this

donz2013 wrote:I know Im probably not explaining this very well, for an example

True :D

donz2013 wrote:in my code it has:

Code: Select all
 <p><img id="imgborder" src="<?php echo base_url();?>img/stairs.jpg" alt="office stairs"/>


when I check the pages source in my browser the
Code: Select all
<?php echo base_url();?>

...part of the code is still in there instead of converting to html and reading something like http://localhost/sitename/

does anyone know why this is,

Does the filename end with .html? PHP code just get parsed in .php files.
Every other issue how to work correct with CodeIgniter should be asked at the CodeIgniter support board.

best wishes,
Altrea

Re: PHP

PostPosted: 04. April 2013 14:00
by donz2013
Hi Altrea,

The missing salutation was a silly oversight on my part, I can assure you there was no rudeness intended what so ever.
I have to point out though what a contradiction it is to give me a lesson on politeness and then a few paragraphs down you comment

"What? I don't understand a word of this"

Re: PHP

PostPosted: 04. April 2013 14:56
by donz2013
Hi all,

Fixed it, Finally

Just thought Id update my query.
Even though some may think that this was not a valid query it may help someone else that may find themselves in my position:

In short, it wont work putting PHP into the database for this instance, :oops:

so simple but only if you know, we all have to start from somewhere :roll: :roll:

For a site called Apache FRIENDS forum it don't feel all that friendly, as far as first experiences it has not been a pleasant one.
Plain and simple... its nice to be nice

Re: PHP

PostPosted: 04. April 2013 15:10
by Altrea
donz2013 wrote:I have to point out though what a contradiction it is to give me a lesson on politeness and then a few paragraphs down you comment

"What? I don't understand a word of this"

Well, I don't know how I can say it with other words. I simply have no clue what these sentences are all about. Maybe it would be more clear if we have had a practical example of which data is stored where.
We don't have any information about your application. Please keep that in mind.

donz2013 wrote:In short, you can't put php into a database :oops:

That's simply not true. A database is just a container for data. The database architecture specifies just the way of storing the data but not which type of data can be stored. In short: Databases can store all types of digital data (including Images, videos, code, music, etc)
Of course you have to make sure that in this place you output the data from the database it will the interpreted the right way.

Best wishes,
Altrea

Re: PHP

PostPosted: 05. April 2013 00:09
by hackattack142
Hello,

To answer your original question, it is possible but you should do it with caution.

Look into this function and at the many examples in the comments of the page: http://php.net/manual/en/function.eval.php