Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8046355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:45:45+00:00 2026-06-05T05:45:45+00:00

Recently I start with php and not because it gives me this error. This

  • 0

Recently I start with php and not because it gives me this error.
This code is onyl for show articles and total price of shopping cart when reload page, using PHPSESSID, if they have a better idea or an alternative for that function, they are appreciated!

INDEX.PHP

<?php require("php/DB_Functionss.php"); ?>
<!doctype html>
<html lang="es">
<head>
    ........
</head>
<body>
    <div id="infoShopCart">
       <a href="contShopping"><img src="img/shopping_cart.png" width="30px"/>
       Artículos: <b id="cantArticles">0</b>
       Total: $ <b id="totalPriceArticles">0.00</b></a>
       <?php getCart(); ?>
    </div>
.....
....
</body>
</html>

AND DB_Functions.php

session_start();
$sessionID = $_COOKIE['PHPSESSID'];

    class DB_Functions {

        private $db;
        //put your code here
        //constructor
        function __construct() {
            require_once 'DB_Connect.php';
            //connecting to database
            $this->db = new DB_Connect();
            $this->db->connect();
        }
        //destructor
        function __destruct() {

        }
      public function getCart(){
            $query ="SELECT * FROM carrito ORDER BY id_pelicula";
            $result = mysql_query($query) or die(mysql_error());

            $no_of_rows = mysql_num_rows($result);
            if($no_of_rows > 0) {
                while ($row = mysql_fetch_assoc($result)) {
                    $totalItems     = $totalItems + 1;
                    $movieTotalPrice    = $movieTotalPrice + $row['precio_pelicula'];
                }
                echo ("Artículos: <b id='cantArticles'>"+$totalItems+"</b><otal: $ <b id='totalPriceArticles'>"+$totalPrice+"</b></a>");
            } else {
                return false;
            }
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T05:45:46+00:00Added an answer on June 5, 2026 at 5:45 am

    You should initialize the object and then use its method. Like so:

    <div id="infoShopCart">
       <a href="contShopping"><img src="img/shopping_cart.png" width="30px"/>
       Artículos: <b id="cantArticles">0</b>
       Total: $ <b id="totalPriceArticles">0.00</b></a>
       <?php
           $db_object = new DB_Functions();
           $db_object->getCart();
       ?>
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently updated to the new version of XCode and the session start code
I recently start to learn PHP. <?php echo (int) ( (0.1+0.7) * 10 );
I recently upgraded to PHP 5.3 and since then I get (sporadic) error messages
I recently found out that PHP not only has the fsock* functions, but also
I've recently come on board with a PHP application. There has not been much
We recently upgraded our PHP and apache versions on our server. Prior to this
i recently start using CodeIgniter as PHP MVC FrameWork , before CodeIgniter, i was
I have recently started to received this message. Unable to start debugging on the
The software group I currently work in has recently decided to start documenting our
I have recently noticed that a lot of JavaScript files on the Web start

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.