Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

OSC Inserting 'Array' into custom 'pdf' db field


gevans

Recommended Posts

Posted

I've added a field to my products table called products_pdf (This is so I can attach a pdf datasheet to a product). To do this I basically copied all the code for adding an image to a product but changed every instance of image to pdf.

 

It works pretty well except for the instance when I update or add a product and don't supply a pdf for it. In this case 'Array' gets inserted into the products_pdf field for that product.

 

The problem this causes is when a customer loads the product_info.php page and 'Array' is the contents of the products_pdf field. When this happens I get a link to www.mystore.com/pdf/Array instead of no link beign displayed.

 

This is the code I use to insert the link for the pdf datasheet:

 

<?php 

   

  	 if ($product_info_values['products_pdf'] != '') echo '<br><a href="' . tep_href_link(DIR_WS_PDF . $pdf) . '">Product Datasheet</a> <img src="images/pdf.gif">';

   ?>

 

I've also tried adding a pdf using the mimage and bimage code structure which doesn't give me this problem however this method seems to forget the pdf's filename whenever that product is updated.

 

Can anybody point me in the right direction to fix this little annoyance?

 

TIA

Posted

Have you tried

<?php 

   

 if ($product_info_values['products_pdf'] != 'Array') echo '<br><a href="' . tep_href_link(DIR_WS_PDF . $pdf) . '">Product Datasheet</a> <img src="images/pdf.gif">';

?>

instead? For debugging purposes, it wouldn't hurt to change the echo to

echo '<-- "' . $product_info_values['products_pdf'] . '" //--><br><a href="' . tep_href_link(DIR_WS_PDF . $pdf) . '">Product Datasheet</a> <img src="images/pdf.gif">';

Note: you will have to View Source in your browser to see the results.

 

Hth,

Matt

I love deadlines. I like the whooshing sound they make as they fly by. ---Douglas Adams

Posted

if(($random != 0) && ($random2 == 1))

{

 

blah blah

}

 

that will allow for two condition statements, unless I'm misunderstanding what you want to do this should work. I have about 8 on one if statement and had to move it to two separate if statements though because of php...so if it doesnt work, try a nested if statement.

Posted

Yes that sounds like a good idea. I was also thinking I could just set the default for the db field to 'Array' and then use the following code

 

if ($product_info_values['products_pdf'] != 'Array')

 

But if anyone has other suggestions I'd appreciate them.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...