Jump to content
Killersites Forums

makamo66

Member
  • Content Count

    18
  • Joined

  • Last visited

Community Reputation

0 Neutral

About makamo66

  • Rank
    Member
  • Birthday 10/23/1966

Profile Information

  • Gender
    Female
  • Location
    New York

Contact Methods

  • Website
    maureenmoore.com

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I have several hundred photos in my image directory because I was previously using ImageMagick and it resized photos every time the page was loaded. What I would like to know is are the images affecting my page loads? Will my site run slower when I have hundreds of images that aren't being loaded but are in the directory? These photos aren't being displayed on the page at all; they are just sitting in the directory.
  2. The var_dump of the $cart_items array is supposed to show an array of $cart_items with the quantities added together for the same id but it doesn't even show an array, it just shows one value. session_start(); $cart_items = $_SESSION["cart_items"]; if ( $cart_items == null ) { $cart_items = array(); } if ( isset($_REQUEST["element_id"]) ) { $id = $_REQUEST["element_id"]; } if ( isset($_REQUEST["quantity"]) ) { $quantity = $_REQUEST["quantity"]; } if ( isset($id) && isset($quantity) ) { if (isset($cart_items[$id])) { $cart_items[$id] += $quantity; } else {
  3. When I echo out my variable in the php file it works fine but when I put the variable in a table cell it doesn't echo out.
  4. When I remove exit it still doesn't work.
  5. The file test2.php consists of these simple forms: <?php for($i=0; $i<=5; $i++){ echo "<form action='reset4.php' method='get' name='yourForm'>"; echo "<button type='submit' value='delete' name='remove_" . $i . "' class='deletebtn'>X</button>"; echo "</form>"; } ?> It submits to reset4.php which is this simple code: <?php header("Location: test2.php"); exit; for($i=0; $i<=5; $i++){ if (isset($_REQUEST["remove_$i"])){ echo "Deleted"; }} ?> But it doesn't work. The $_REQUEST doesn't populate the address field and it apparently neve
  6. This is the cart array: $cart = array( "1" => "2", "3" => "4", "5" => "6"); var_dump($cart); array(3) { [1]=> string(1) "2" [3]=> string(1) "4" [5]=> string(1) "6" } This is the cart items array: $cart_items = array(); $cart_items["id"] = $id; $cart_items["quantity"] = $quantity; var_dump($cart_items); array(2) { ["id"]=> array(2) { [0]=> string(1) "1" [1]=> string(1) "1" } ["quantity"]=> array(2) { [0]=> string(1) "1" [1]=> string(1) "1" } } I want the key to be "id" and the value to be "quantity" like it is for the cart array. How do
  7. If you were working on a PHP shopping cart using SESSION variables for the cart item's product id and quantity, how would you update the cart if the same product were chosen? If the same product id was posted, how would you add the quantities and show just the same product?
  8. This is the code that I'm using for a shopping cart in order to update the quantity if the same product id is chosen. $cart_items is a two-dimensional session array composed of the id session array and the quantity session array. While looping through $cart_items, I create a temporary array $temp_array so that I can execute some logic on the array without changing the normal output. $temp_array is the $cart_items array without the last items which would be the $_REQUEST id and the $_REQUEST quantity. So the two $_REQUESTs are popped off with array_pop and then the remaining $_SESSIONs ar
  9. I retract my original question because I don't need to make my multidimensional-array any larger after all. Please ignore my post.
  10. The solution can't include nested foreach loops because I will be adding 3 more inner arrays to the multidimensional array and when I do this with nested foreach loops, I need 6 of them.
  11. <?php $_SESSION["cart_item"] = array( 'cart_item' => array( 'id' => $id, 'product_name' => $product_name )); } $cart_items = $_SESSION["cart_item"]; foreach ($cart_items as $cart_item) { echo $cart_item["id"] . $cart_item["product_name"]; } ?> I have tried several variations of the foreach loop like the one above and I mostly get the error message: Notice: Array to string conversion. When I use: var_dump($cart_items); I get the following output: array(1) { ["cart_item"]=> array(2) { ["id"]=> array(2) { [0]=> string(1) "2" [1]=> string(1) "3" } ["produ
  12. I want to use array_pop to remove the last item added to the SESSION array. So it would remove the REQUEST item. The problem is that nothing is left in the session array because I pop off the last item each time that the form is submitted. Maybe I need to use array_push to push the popped items back on to the SESSION array after the logic has been applied. I don't understand how array_pop is supposed to work on a SESSION array. Can anyone explain to me what behaviour to expect? I expected to get a SESSION array with the REQUEST item removed but I thought that I would still have all of my SESSI
  13. The solution posted to a different forum was: $sql = "INSERT INTO comment_table (name,date_col,website,comment) VALUES (?, ?, ?, ?)";
  14. I changed the code so that it is using prepared statements but I just get new errors now. I altered the table so that the date_col column has the data type of varchar. I get the following warning: mysqli_stmt_bind_param(): Number of variables doesn't match number of parameters in prepared statement if(isset($_REQUEST["submit"]) ) { $date = new DateTime('', new DateTimeZone('America/New_York')); $name = mysqli_real_escape_string($connection, $_REQUEST["name"]); $date_col = $date->format('M d, Y H:i'); $website = $_REQUEST["website"]; $comment = mysqli_real_escape_string($connection,
  15. I added a column to my database with SQL as follows: ALTER TABLE comment_table ADD date_col Datetime NOT NULL; I try to insert into the database with the following PHP but nothing gets inserted. if(isset($_POST["submit"])) { $date_col = "test";//this will be DateTime later $name = $_POST["name"]; mysqli_query($connection, "INSERT INTO comment_table (name, date_col) VALUES ('$name', '$date_col')"); } $comsql = "SELECT * FROM comment_table"; $comres = mysqli_query($connection, $comsql); while($comr = mysqli_fetch_assoc($comres)){ ?> <div class
×
×
  • Create New...