Monday, November 16, 2009

Code for shopping cart?

i'm trying to echo a command on a php page to an html page. The command is to show the quantity of contents in a shopping cart. ( OsC)


command on original shopping cart page is:


$cart-%26gt;count_contents()


source file is:


shopping_cart.php under public_html/catalog/


echo in:


public_html/index.htm (has its own shopping cart image with text table)


tried something like this, but can't figure out the winning combo:


%26lt;tr%26gt;


%26lt;td width="3%"%26gt; %26lt;/td%26gt;


%26lt;td width="94%"%26gt;%26lt;font size="1"%26gt;You have %26lt;a class=ml1 href="http://mysite.com/catalog/shopping... echo %26gt;count_contents()';http://mysite.com/catalog/shopping_cart.... ?%26gt; item(s)%26lt;/a%26gt;


in your cart.%26lt;td width="3%"%26gt;%26lt;/td%26gt;


%26lt;/tr%26gt;


%26lt;/table%26gt;





...sorry this page is abbreviating things...

Code for shopping cart?
You get some expert help from http://ccietutorial.com/
Reply:From what I see, you're missing the ?


%26lt;?php ?%26gt;


instead of


%26lt;php ?%26gt;





alternatively you may use


%26lt;? ?%26gt; shorthand, not supported by all servers





If there's another mistake, please rephrase the question, add extra whitespaces wherever whitespace can be safely added





EDIT:


Try this:


You have %26lt;?php global $cart; echo $cart-%26gt;count_contents(); ?%26gt; item(s)





or have you checked that php is actually enabled for the page you're modifying? Are you running this script on a server or you directly open this from a browser? Since PHP requires server-side scripting it must be run from a real server. You may set up a local server with XAMPP: http://www.apachefriends.org/en/xampp.ht...





Try a simple test script like this to test it:


%26lt;?php echo "Hello World" ?%26gt;


if it doesn't show anything or instead shows the code, you're not in a php-environment. Upload the file to a real server or setup a local server. Also make sure that php is enabled for the directory you're using.


No comments:

Post a Comment