Jump to content

php in mysql database


fixxxer

Recommended Posts

Hey,

 

This might sound like an easy question but im stuck, in the website im building i want to store php code snippets in a table on the database and call them when i need them. When i try and put the code onto the site though the code just prints out to the page, can someone tell me what im doing wrong, is there a function i need to use to make it act as php code or am i just barking up the wrong tree.

 

if anyone could point me in the right direction id be grateful

 

thanks

 

Link to comment
Share on other sites

If you are wanting to use the same PHP code over and over, you could try creating your own functions.

 

create a functions.php page, which includes all your created functions. Include the functions.php in your main php page and you can call them all from there.

 

I'm not to sure if this is what you are looking for though.

Link to comment
Share on other sites

If you are wanting to use the same PHP code over and over, you could try creating your own functions.

 

create a functions.php page, which includes all your created functions. Include the functions.php in your main php page and you can call them all from there.

 

I'm not to sure if this is what you are looking for though.

 

thanks for the reply, i already have a function file. Basically the snippets of codes make up css boxes and i wanted to be able to get them dynamically depending on what page the user is on, it works fine when i dont put php code in the boxes but as soon as i do it just prints out the code as well, when i want it to print the display code and then execute the php commands.

 

sorry if this doesn't make sense.

Link to comment
Share on other sites

if you have any code that you can post, it would help out!

 

 

well this is the info that i want to come from the database. it is taken from the database and when placed into the page it i want to get to act as php code but when i for example store it as a variable $box and use echo $box it just prints it to the page. I want it to be executed as php code, but its just printed straight on the page. i know im doing something wrong but cant work out what.

 

$result = get_match_info($_REQUEST['id']);

$row = mysql_fetch_array($result);

 

echo "Competition: " . $row['name'] . "<br />";

echo "Date Added: " . $row['date_added'] . "<br />";

 

 

Link to comment
Share on other sites

i thought it might be that i couldnt store code in the database, thanks for letting me know.

 

You could (can), but its usually a poor design choice.

 

yeah to be honest ive been pulling my hair out at it for a couple of hours and beginning to realise it wouldn't have worked as well as i wanted to anyway. thanks for the help everyone, with out posting here prob would have wasted a week. thanks.

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.