yarub Posted August 22, 2009 Share Posted August 22, 2009 I have a database with a table. In this table, I have a field for content. In this field.. I would like to be able to type $variable for instance and it know what I'm referring to. I have $variable designed earlier as "hamburger" and I would like it to pull up hamburger when I call for it through a mysql_fetch_array. So saved into the database is "$variable" and not hamburger. But I would like it to say hamburger when it prints out. Can anyone help me? Quote Link to comment Share on other sites More sharing options...
trq Posted August 22, 2009 Share Posted August 22, 2009 PHP is meant to be written in files, why people insist on attempting to store it within a database is beyond me (your not the first however to ask this question). Take a look at eval. Quote Link to comment Share on other sites More sharing options...
Alex Posted August 22, 2009 Share Posted August 22, 2009 PHP is meant to be written in files, why people insist on attempting to store it within a database is beyond me (your not the first however to ask this question). Take a look at eval. I don't think that's what he means. It sounds to me like you're trying to store the the value of $variable instead you're storing the string '$variable' it self. If I'm correct show us the code used to preform that insert into the database so we can tell you how to fix it. Quote Link to comment Share on other sites More sharing options...
yarub Posted August 22, 2009 Author Share Posted August 22, 2009 No no. Thorpe got me exactly what I wanted. I defined $variable elsewhere in a config script and I actually placed $variable into the content field in my database. Now when I write posts on my main page, I can call $variable instead of writing everything out. For instance, if I changed the name of my website, every post changes. Probably a bad way of doing it, but it's just a quick project. Thank you! Quote Link to comment Share on other sites More sharing options...
trq Posted August 22, 2009 Share Posted August 22, 2009 Probably a bad way of doing it, but it's just a quick project. Pff. Does that mean its not important? Your code should suffer? Me, I try to make each project an improvement on the previous. 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.