ollyno1uk2 Posted April 12, 2008 Posted April 12, 2008 I have been trying to add a php vairable directly into the table products_description.products_description but it does not work as I had hoped. Am I not considering another factor that could stop this working? Thanks in advance
Guest Posted April 12, 2008 Posted April 12, 2008 I don't think you can put a php inside php. <?php echo stripslashes($product_info['products_description']); ?> Try it without adding an additional php tag or close the php tag and then reopen it. ?><?php my variable ?><php Not sure if that will work, I have never tried it.
ollyno1uk2 Posted April 12, 2008 Author Posted April 12, 2008 Thanks for taking the time to help but this does not solve it - It just echos a ?> ANy other ideas?
germ Posted April 12, 2008 Posted April 12, 2008 Post your PHP code. Sounds like you have a slight syntax problem. You don't need to post the whole page, just the little snippet that's giving you problems. If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there >
ollyno1uk2 Posted April 12, 2008 Author Posted April 12, 2008 Hi thanks It is a simple addition <hr><br> <table> <tr> <td class = "smalltext"> <?php echo $rrp; ?> </td> </tr> </table> <br> <hr> This is dropped into the description and shows the RRP - the variable works anywhere on the products_info.php page but not if I insert into the table within the products description text
ollyno1uk2 Posted April 12, 2008 Author Posted April 12, 2008 could I perhaps do it another way and show only the product description up to a certain word, then echo the string within product_info.php and then run a final echo of the remaining products_description field? Maybe this is a long winded way of doing it but I'm not sure how to try it. Thanks
♥FWR Media Posted April 12, 2008 Posted April 12, 2008 There is html with PHP inclusions and html parsed by PHP they have two seperate syntax. PHP inclusions: <table> <tr> <td><?php echo $imavariable; ?></td> </tr> </table> HTML parsed by PHP <?php echo ' <table> <tr> <td>' . $imavariable . '</td> </tr> </table>'; ?> You also have to be aware of how quotes are being used because the above can also be written .. <?php echo " <table> <tr> <td>$imavariable</td> </tr> </table>"; ?> The difference being the use of single or double opening/closing quotes. Hope that helps Ultimate SEO Urls 5 PRO - Multi Language Modern, Powerful SEO Urls KissMT Dynamic SEO Meta & Canonical Header Tags KissER Error Handling and Debugging KissIT Image Thumbnailer Security Pro - Querystring protection against hackers ( a KISS contribution ) If you found my post useful please click the "Like This" button to the right. Please only PM me for paid work.
germ Posted April 12, 2008 Posted April 12, 2008 Without seeing more code, all I can think of is an alignment problem. Maybe this: <td class = "smalltext"> Needs to be something like: <td class = "smalltext" align="center"> :unsure: If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there >
ollyno1uk2 Posted April 12, 2008 Author Posted April 12, 2008 I think what I am doing is correct but as the php is within the products_decsription table, it doesn't respond for some reason
♥FWR Media Posted April 12, 2008 Posted April 12, 2008 I think what I am doing is correct but as the php is within the products_decsription table, it doesn't respond for some reason If what you were doing was correct it would work :) Ultimate SEO Urls 5 PRO - Multi Language Modern, Powerful SEO Urls KissMT Dynamic SEO Meta & Canonical Header Tags KissER Error Handling and Debugging KissIT Image Thumbnailer Security Pro - Querystring protection against hackers ( a KISS contribution ) If you found my post useful please click the "Like This" button to the right. Please only PM me for paid work.
ollyno1uk2 Posted April 12, 2008 Author Posted April 12, 2008 Lol - yes that is true! here i some more code as I don't get it - this is direct fromthe products_description table and products_description field. <p>text heret.</p><br><br> <hr><br> <table> <tr> <td class = "smalltext" align = "center"> <?php echo '123'; ?> </td> </tr> </table> <br> <hr> <br> <br><B>Specs</B>................... I have made it 123 to make it easier to see where it is going wrong and nothing is outputted. Thanks a lot
♥FWR Media Posted April 12, 2008 Posted April 12, 2008 This is dropped into the description and shows the RRP - the variable works anywhere on the products_info.php page but not if I insert into the table within the products description text What do you mean "within the products description text" are you talking about adding text in admin? Ultimate SEO Urls 5 PRO - Multi Language Modern, Powerful SEO Urls KissMT Dynamic SEO Meta & Canonical Header Tags KissER Error Handling and Debugging KissIT Image Thumbnailer Security Pro - Querystring protection against hackers ( a KISS contribution ) If you found my post useful please click the "Like This" button to the right. Please only PM me for paid work.
germ Posted April 12, 2008 Posted April 12, 2008 Do something like this: <hr><br> <table> <tr> <td class = "smalltext"> <!-- here is my PHP variable --> <?php echo $rrp; ?> <!-- there was my PHP variable --> </td> </tr> </table> <br> <hr> Then look at the HTML source for those comments. That will ensure PHP is getting to your code. I have no further suggestions without more code to look at, or a URL to visit to see for myself. If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there >
ollyno1uk2 Posted April 12, 2008 Author Posted April 12, 2008 The source results in an empty table cell. FWR - yes I am inserting the php into the table field iteself within the text of that field. In products_description.products_description
♥FWR Media Posted April 12, 2008 Posted April 12, 2008 The source results in an empty table cell. FWR - yes I am inserting the php into the table field iteself within the text of that field. In products_description.products_description You wont get it to work. You can't add PHP code via admin nor through MySQL. You could get it to work by adding a placeholder then replacing it with the variable via str_replace in the outputting file. Ultimate SEO Urls 5 PRO - Multi Language Modern, Powerful SEO Urls KissMT Dynamic SEO Meta & Canonical Header Tags KissER Error Handling and Debugging KissIT Image Thumbnailer Security Pro - Querystring protection against hackers ( a KISS contribution ) If you found my post useful please click the "Like This" button to the right. Please only PM me for paid work.
ollyno1uk2 Posted April 12, 2008 Author Posted April 12, 2008 Ah right - this was my suspicion - Is there a way around it? Or is it inbuilt to OSC? What are my options as far as attempting to split the text of products_description so I can insert the variable into products_info.php in between the two halves? Thanks for your help BTW
♥FWR Media Posted April 12, 2008 Posted April 12, 2008 Ah right - this was my suspicion - Is there a way around it? Or is it inbuilt to OSC? What are my options as far as attempting to split the text of products_description so I can insert the variable into products_info.php in between the two halves? Thanks for your help BTW Here is an example: - <?php $text = 'This is some text ---placeholder--- this is some more text'; $replace = 'I replaced the placeholder'; $text = str_replace('---placeholder---', $replace, $text); echo $text; ?> Ultimate SEO Urls 5 PRO - Multi Language Modern, Powerful SEO Urls KissMT Dynamic SEO Meta & Canonical Header Tags KissER Error Handling and Debugging KissIT Image Thumbnailer Security Pro - Querystring protection against hackers ( a KISS contribution ) If you found my post useful please click the "Like This" button to the right. Please only PM me for paid work.
♥FWR Media Posted April 12, 2008 Posted April 12, 2008 In product_info.php it would look like the following: - I found this line . . <p><?php echo stripslashes($product_info['products_description']); ?></p> It would look like ... <p> <?php $myvar = '123'; // Hopefully this wouldn't be hardcoded if (isset($myvar)) { // In case it is optional $product_info['products_description'] = str_replace('---placeholder---', $myvar, $product_info['products_description']); } echo stripslashes($product_info['products_description']); ?> </p> Ultimate SEO Urls 5 PRO - Multi Language Modern, Powerful SEO Urls KissMT Dynamic SEO Meta & Canonical Header Tags KissER Error Handling and Debugging KissIT Image Thumbnailer Security Pro - Querystring protection against hackers ( a KISS contribution ) If you found my post useful please click the "Like This" button to the right. Please only PM me for paid work.
ollyno1uk2 Posted April 12, 2008 Author Posted April 12, 2008 Yes this does seem to work well - this means I can now ge back to editing only the product_info.php - that is really top stuff - thanks a lot - learnt something new as well! Cheers
Guest Posted June 10, 2008 Posted June 10, 2008 Hi I know no one has added to this thread for a few weeks but can you help me. I want to add an extra field between the Product Name and Product Price, I worked out where it has to go and have put a table cell there and inputed some text to make sure this is correct place. I have created the field in the products table and called it products_weightdisplay, what I need is depending on the product to have a choice of three text fields that will relate the price either to a kilo price, a pack price and another one. I've hunted through the contributions and forums and can't find anything that totally matches my requirements. Any help is greatly appreciated.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.