fixxxer Posted July 16, 2007 Share Posted July 16, 2007 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 Quote Link to comment Share on other sites More sharing options...
envexlabs Posted July 16, 2007 Share Posted July 16, 2007 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. Quote Link to comment Share on other sites More sharing options...
fixxxer Posted July 16, 2007 Author Share Posted July 16, 2007 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. Quote Link to comment Share on other sites More sharing options...
envexlabs Posted July 16, 2007 Share Posted July 16, 2007 if you have any code that you can post, it would help out! Quote Link to comment Share on other sites More sharing options...
fixxxer Posted July 16, 2007 Author Share Posted July 16, 2007 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 />"; Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted July 16, 2007 Share Posted July 16, 2007 You shouldn't be storing PHP code directly into the database to execute. Store the code in a file and use include() or use functions like someone else suggested. Quote Link to comment Share on other sites More sharing options...
fixxxer Posted July 16, 2007 Author Share Posted July 16, 2007 i thought it might be that i couldnt store code in the database, thanks for letting me know. Quote Link to comment Share on other sites More sharing options...
trq Posted July 16, 2007 Share Posted July 16, 2007 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. Quote Link to comment Share on other sites More sharing options...
fixxxer Posted July 16, 2007 Author Share Posted July 16, 2007 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.