Jump to content

Supervan

Members
  • Posts

    52
  • Joined

  • Last visited

Everything posted by Supervan

  1. Hi, I need to dump php / html output of a single page to "Swifmailer" I was prevouisly using the $MesBody = <<<ENDFF1 ..... php generated text ENDFF1; Any other recomodations.
  2. Hi, I’m using PHP OOP and created an instance of the class and stored the content inside a $_SESSION['cart'] 1... I can validate, if “prid” exists in the session with this …. How would i check for "prid" and "prflavour" Mango ? if (isset($_SESSION['cart'][12])) 2... I need to update the quantity when both conditions "prid" and "prflavour" are met. how do i change this $_SESSION['cart'][$_GET['prid']]-> to work with prid and prflavour $_SESSION['cart'][$_GET['prid']]->updateQuantity(123) sample of the $_SESSION['cart'] Array ( [13] => Item Object ( [prid:protected] => 13 [prname:protected] => Meal [prflavour:protected] => Mango [prqty:protected] => 10 ) [12] => Item Object ( [prid:protected] => 12 [prname:protected] => Milk [prflavour:protected] => [prqty:protected] => 123 ) )
  3. hi The value of the input tag need to be added to a href tag. Is it possible to get the value of qty1 without using jquery or posting of a form. Need to create <a Href tag.. echo "<td> <input type=\"text\" name=\"qty1\" id=\"qty1\" autocomplete=\"off\"></td>" . "<td><a href=\"index123.php?qty1='+document.getElementById('qty1').value'&prodid=" . $product1->id . "\">add product</a>"
  4. On the clean win 7 machine... installed uwamp... same issue with vhost.sourceforge.net. I thought let me allow it to connect once... maybe an update. works fine until you restart your pc and start uwamp.... then it starts phones back to vhost.sourceforge.net. I think all the applications for windows using the same code from sourceforge, if im wrong sorry....... Comments recommendation welcome... The apache version 2.22.2 is clean only the later versions have this issue..
  5. I have a other win7 pc that is clean. (Only win7 and Office loaded.) Will install the application and see whats the story... Thanks
  6. Hi, XAMPP software... If I click on mysql Admin. getting an outband traffic request to vhost.sourceforge.net ip 216.34.181.97 remote port 80 local 49489 its not my host file.. if you ping vhost.sourceforge.net with your "127.0.0.1 vhost... ) example you will a reply van localhost. Im getting from 216.34.181.97 I also checked my hosts. entry not found. The phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated.
  7. I tried another one XAMPP 3.2.1.. on windows.. If i start the mysql and click on the admin button.. it tries to connect to vhost.sourceforge.net. Any ideas how to solve this.. ?
  8. just do a quick test... wamp phone home everytime u use it... just disable you internet and try to use phpmyadmin. Restart your pc and then do the test...
  9. Hi, Im currently running wamp with Apache:2.2.22 and PHP 5.4.31 on windows 7 I want to use Apache 2.4?? but it requires a connection to the internet to authenticate something with vhost.sourceforge.net If you block access PHPMyAdmin / MYsql stop working. You can test my theory... block access to vhost.sourceforge.net and mysql stop working. I tried it with Wamp server, UwAmp, Uniform_Server Thanks
  10. Thanks for your input... I’m using an autoloader for the classes. The problem was intermittent. After I hardcoded the require_once it seems to be stable. I was also using a older version of wamp with apache 2.22.2
  11. getting problems with wamp. Had problems with session management. Store a class array inside session and then all the fun starts
  12. getting problems with wamp. Had problems with session management. Store a class array inside session and then all the fun starts
  13. Looking for Easy setup apache PHP MYSQL on windows Please dont say.... wamp....
  14. I really appreciate all the time and afford. Thank you very much I have a 2nd php file to destroy the session. Found a duplicate print_r... that was the cause of the duplication. been struggling for the last 2 days with little sleep.. Im starting to think it is the wamp server im using.. i can give you teamviewer access to my pc... i really dont know what is wrong... 1. clear session.. 2. select 1 product New product will be added. Array ( [1] => Item Object ( [id:protected] => 1 [name:protected] => Jungle Book [description:protected] => Book about jungle animals [price:protected] => 150 [shipping:protected] => 6 [quantity:protected] => 1 [subtotal:protected] => ) ) My Shopping Cart 1 Jungle Book Book about jungle animals 150 6 1 3. select same item Prodid found, quantity will be adjusted ( ! ) Fatal error: main(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "Item" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in G:\www\oop\index123.php on line 41 4. Select a different product. New product will be added. Array ( [1] => __PHP_Incomplete_Class Object ( [__PHP_Incomplete_Class_Name] => Item [id:protected] => 1 [name:protected] => Jungle Book [description:protected] => Book about jungle animals [price:protected] => 150 [shipping:protected] => 6 [quantity:protected] => 1 [subtotal:protected] => ) [2] => Item Object ( [id:protected] => 2 [name:protected] => PC Format [description:protected] => Pc format no more [price:protected] => 10 [shipping:protected] => 51 [quantity:protected] => 1 [subtotal:protected] => ) ) My Shopping Cart ( ! ) Fatal error: main(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "Item" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in G:\www\oop\index123.php on line 75 <?php require_once 'core/init.php'; $product = db::getInstance()->query('SELECT * FROM products'); if ($product->count()) { echo "<table cellpadding='5' cellspacing='5' border='1'> " . "<tr><th>Products Available</th></tr>" . "<tr>" . "<th>Id</th>" . "<th>Name</th>" . "<th>Description</th> " . "<th>Price</th>" . "<th>Shipping</th>" . "<th>Quantity</th>" . "</tr>"; foreach ($product->results() as $product1) { echo "<tr>" . "<td>" . $product1->id . "</td>" . "<td>" . $product1->name . "</td>" . "<td>" . $product1->description . "</td>" . "<td>" . $product1->price . "</td>" . "<td>" . $product1->shipping . "</td>" . "<td>" . $product1->quantity . "</td>" . "<td><a href=\"index123.php?prodid=" . $product1->id . "\">Take me home</a>" . "</tr>"; } echo "</table>"; } if (isset($_GET['prodid'])) { // Check product if exists in cart, add quantities together if (isset($_SESSION['cart'][$_GET['prodid']])) { echo 'Prodid found, quantity will be adjusted </br>'; $_SESSION['cart'][$_GET['prodid']]->updateQuantity(10); // for now it increment with 10 } else { // create new item... need to do... if prodid not found.... $parms = array(); $parms[] = array(':id', $_GET['prodid'], PDO::PARAM_INT); $productid = db::getInstance()->query("SELECT * FROM products WHERE id = :id", $parms); if ($productid->count()) { foreach ($productid->results() as $result) { $item = new Item($result->id, $result->name, $result->description, $result->price, $result->shipping, 1); echo 'New product will be added.</br>'; $_SESSION['cart'][$_GET['prodid']] = $item; } } } } // Delete product in cart if (isset($_GET['delinfo'])) { unset($_SESSION['cart'][$_GET['delinfo']]); } //Loop thru $_SESSION['cart' and display content if (isset($_SESSION['cart'])) { echo '<pre>'; print_r($_SESSION['cart']); echo '</pre>'; $total = 0; echo "<table cellpadding='5' cellspacing='5' border='1'>" . "<tr><th>My Shopping Cart</th></tr>"; foreach ($_SESSION['cart'] as $id => $item) { // $total += $item->getSubtotal(); echo "</tr>" . "<td>" . $item->getId() . "</td>" . "<td>" . $item->getName() . "</td>" . "<td>" . $item->getDescription() . "</td>" . "<td>" . $item->getPrice() . "</td>" . "<td>" . $item->getShipping() . "</td>" . "<td>" . $item->getQuantity() . "</td>" // . "<td>" . $item->getSubtotal() . "</td>" . "<td><a href=\"index123.php?delinfo=" . $item->getId() . ">Delete </a></td>" . "</tr>"; } echo "<tr>" . "<td colspan='6'align='right'>Total amount</td>" . "<td align='left'>" . $total . "</td></tr>" . "</table>"; } ?> <?php # Item.php // This is a sample Item class. // This class could be extended by individual applications. class Item { protected $id; protected $name; protected $description; protected $price; protected $shipping; protected $quantity; protected $subtotal; // Constructor populates the attributes: public function __construct($id, $name, $description, $price, $shipping, $quantity) { $this->id = $id; $this->name = $name; $this->description = $description; $this->price = $price; $this->shipping = $shipping; $this->quantity = $quantity; } // Method that returns the ..... public function getId() { return $this->id; } public function getName() { return $this->name; } public function getDescription() { return $this->description; } public function getPrice() { return $this->price; } public function getShipping() { return $this->shipping; } public function getQuantity() { return $this->quantity; } public function getSubtotal() { $this->subtotal = ($this->price * $this->quantity) + $this->shipping; return $this->subtotal; } public function updateQuantity($quantity) { $this->quantity += $quantity; } }
  15. Hi Mac_gyver, Thanks for your help I selected two different products. The Array 1 can't be right.... print_r dump New product will be added. Array ( [1] => __PHP_Incomplete_Class Object ( [__PHP_Incomplete_Class_Name] => Item [id:protected] => 1 [name:protected] => Jungle Book [description:protected] => Book about jungle animals [price:protected] => 150 [shipping:protected] => 6 [quantity:protected] => 1 [subtotal:protected] => 156 ) [2] => Item Object ( [id:protected] => 2 [name:protected] => PC Format [description:protected] => Pc format no more [price:protected] => 10 [shipping:protected] => 51 [quantity:protected] => 1 [subtotal:protected] => ) ) Array ( [1] => __PHP_Incomplete_Class Object ( [__PHP_Incomplete_Class_Name] => Item [id:protected] => 1 [name:protected] => Jungle Book [description:protected] => Book about jungle animals [price:protected] => 150 [shipping:protected] => 6 [quantity:protected] => 1 [subtotal:protected] => 156 ) [2] => Item Object ( [id:protected] => 2 [name:protected] => PC Format [description:protected] => Pc format no more [price:protected] => 10 [shipping:protected] => 51 [quantity:protected] => 1 [subtotal:protected] => ) ) if (isset($_GET['prodid'])) { // Check product if exists in cart, add quantities together if (isset($_SESSION['cart'][$_GET['prodid']])) { echo 'Prodid found, quantity will be adjusted </br>'; $_SESSION['cart'][$_GET['prodid']]->updateQuantity(10); // for now it increment with 10 print_r($_SESSION['cart']); } else { // create new item... need to do... if prodid not found.... $parms = array(); $parms[] = array(':id', $_GET['prodid'], PDO::PARAM_INT); $productid = db::getInstance()->query("SELECT * FROM products WHERE id = :id", $parms); //This should only be one record.. how can i retrieve it without loop... if ($productid->count()) { foreach ($productid->results() as $result) { $item = new Item($result->id, $result->name, $result->description, $result->price, $result->shipping, 1); } } echo 'New product will be added.</br>'; $_SESSION['cart'][$_GET['prodid']] = $item; // not sure if this is correct print_r($_SESSION['cart']); } }
  16. Thanks for responding... The error that im getting Fatal error: Call to a member function getSubtotal() on a non-object in G:\www\oop\index123.php on line 72 line 72. $total += $item->getSubtotal(); This is what print_r session display found __PHP_Incomplete_Class Object ( [__PHP_Incomplete_Class_Name] => Item [id:protected] => 1 [name:protected] => Book [description:protected] => This is a book [price:protected] => 150 [shipping:protected] => 6 [quantity:protected] => 1 [subtotal:protected] => 156 ) + The error that im getting Fatal error: Call to a member function getName() on a non-object in G:\www\oop\index123.php on line 75 line 75. . "<td>" . $item->getName() . "</td>" This is what print_r session display found __PHP_Incomplete_Class Object ( [__PHP_Incomplete_Class_Name] => Item [id:protected] => 2 [name:protected] => Tea [description:protected] => Rooibos [price:protected] => 10 [shipping:protected] => 51 [quantity:protected] => 1 [subtotal:protected] => ) if (isset($_GET['prodid'])) { // create new item $parms = array(); $parms[] = array(':id', $_GET['prodid'], PDO::PARAM_INT); $productid = db::getInstance()->query("SELECT * FROM products WHERE id = :id", $parms); if ($productid->count()) { foreach ($productid->results() as $result) { $item = new Item($result->id, $result->name, $result->description, $result->price, $result->shipping, 1); } } // Check product if exists in cart, add quantities together if (isset($_SESSION['cart'][$result->id])) { echo 'found </br>'; print_r($_SESSION['cart'][$result->id]); $_SESSION['cart'][$result->id] = $item->updateQuantity(10); // for now it increment with 10 } else { echo 'not found </br>'; print_r($_SESSION['cart'][$result->id]); $_SESSION['cart'][$result->id] = $item; } } // Delete product in cart if (isset($_GET['delinfo'])) { unset($_SESSION['cart'][$_GET['delinfo']]); } //Loop thru $_SESSION['cart' and display content $total=0; echo "<table cellpadding='5' cellspacing='5' border='1'>" . "<tr><th>My Shopping Cart</th></tr>"; foreach ($_SESSION['cart'] as $id => $item) { $total += $item->getSubtotal(); echo "</tr>" . "<td>" . $id . "</td>" . "<td>" . $item->getName() . "</td>" . "<td>" . $item->getDescription() . "</td>" . "<td>" . $item->getPrice() . "</td>" . "<td>" . $item->getShipping() . "</td>" . "<td>" . $item->getQuantity() . "</td>" . "<td>" . $item->getSubtotal() . "</td>" . "<td><a href=\"index123.php?delinfo=" . $id . ">Delete </a></td>" . "</tr>"; } echo "<tr>" . "<td colspan='6'align='right'>Total amount</td>" . "<td align='left'>" . $total . "</td></tr>" . "</table>"; ?> my class class Item { protected $id; protected $name; protected $description; protected $price; protected $shipping; protected $quantity; protected $subtotal; // Constructor populates the attributes: public function __construct($id, $name, $description, $price, $shipping, $quantity) { $this->id = $id; $this->name = $name; $this->description = $description; $this->price = $price; $this->shipping = $shipping; $this->quantity = $quantity; } // Method that returns the ..... public function getId() { return $this->id; } public function getName() { return $this->name; } public function getDescription() { return $this->description; } public function getPrice() { return $this->price; } public function getShipping() { return $this->shipping; } public function getQuantity() { return $this->quantity; } public function getSubtotal() { $this->subtotal = ($this->price * $this->quantity) + $this->shipping; return $this->subtotal; } public function updateQuantity($quantity) { $this->quantity = $this->quantity + $quantity; } }
  17. Hi Barand, I dont like doing this ... Please take a look at the code... Got it to work up to a point... received funny error message .... incomplete something array... I restarted wamp and cleared my browser cache... Im getting the feeling it's not accepting session storage... My Program .... $item = new Item($result->id, $result->name, $result->description, $result->price, $result->shipping, 1); // Check product if exists in cart, add quantities together if (isset($_SESSION['cart'][$result->id])) { $_SESSION['cart'][$result->id] = $item->updateQuantity(10); } else { $_SESSION['cart'][$result->id] = $item; } } // Delete product in cart if (isset($_GET['delinfo'])) { unset($_SESSION['cart'][$_GET['delinfo']]); } //Loop thru $_SESSION['cart' and display content foreach ($_SESSION['cart'] as $id => $item) { $total = $item->getSubtotal(); echo "<table cellpadding='5' cellspacing='5' border='1'><tr> " . "<tr><th>My Shopping Cart</th></tr>" . "<td>" . $id . "</td>" . "<td>" . $item->getName() . "</td>" . "<td>" . $item->getDescription() . "</td>" . "<td>" . $item->getPrice() . "</td>" . "<td>" . $item->getShipping() . "</td>" . "<td>" . $item->getQuantity() . "</td>" . "<td>" . $item->getSubtotal() . "</td>" . "<td><a href=\"index123.php?delinfo=" . $id . ">Delete </a></td>" . "</tr>"; } echo "<tr>" . "<td colspan='6'align='right'>Total amount</td>" . "<td align='left'>" . $total . "</td>" . "</table>"; ? The full class... all should be ok with the class class Item { protected $id; protected $name; protected $description; protected $price; protected $shipping; protected $quantity; protected $subtotal; // Constructor populates the attributes: public function __construct($id, $name, $description, $price, $shipping, $quantity) { $this->id = $id; $this->name = $name; $this->description = $description; $this->price = $price; $this->shipping = $shipping; $this->quantity = $quantity; } // Method that returns the ..... public function getId() { return $this->id; } public function getName() { return $this->name; } public function getDescription() { return $this->description; } public function getPrice() { return $this->price; } public function getShipping() { return $this->shipping; } public function getQuantity() { return $this->quantity; } public function getSubtotal() { $this->subtotal = ($this->price * $this->quantity) + $this->shipping; return $this->subtotal; } public function updateQuantity($quantity) { $this->quantity = $this->quantity + $quantity; } }
  18. It does work.. Thx.. Getting an undefined index if i try to read the info inside the $cart.. I removed the 2 lines from the del process. $cart = array_values($cart); $_SESSION['cart'] = $cart; $cart = unserialize(serialize($_SESSION['cart'][$result->id])); for ($i = 0; $i < count($cart); $i++) { echo "<table><tr>" . "<td>" . $cart[$i]->getId() . "</td>" . "<td>" . $cart[$i]->getName() . "</td>" . "<td><a href=\"index1.php?delinfo=" . $i . ">Delete </a></td>" . "</tr></table"; }
  19. Hi Barand, Thanks for responding. Im tried with a couple of options to get it working. Is all to do with key and I dont know how to apply it... getting... this error... Undefined property: Item::$getId //My Items class variables are protected. class Item { protected $id; protected $name; public function getId() { return $this->id; } .... Add instance and display message when item found. // Connect to db and store results in item ..... $item = new Item($result->id, $result->name); // Check product if existing in cart $cart = unserialize(serialize($_SESSION['cart'][$item->getId])); $_SESSION['cart'][$item->getId] = $item; for ($i = 0; $i < count($cart); $i++) if ($cart[$i]->getId() == $_GET['prodid']) { echo 'Item already exists'; break; } Delete product in cart... if (isset($_GET['delinfo'])) { $cart = unserialize(serialize($_SESSION['cart'][$item->getId])); unset($_SESSION['cart'][$_GET['delinfo']]); $cart = array_values($cart); $_SESSION['cart'] = $cart; } Read Session Cart and display info $cart = unserialize(serialize($_SESSION['cart'][$item->getId])); for ($i = 0; $i < count($cart); $i++) { echo "<table><tr>" . "<td>" . $cart[$i]->getId() . "</td>" . "<td>" . $cart[$i]->getName() . "</td>" . "<td><a href=\"index1.php?delinfo=" . $i . ">Delete </a></td>" . "</tr></table"; }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.