Jump to content

lional

Members
  • Posts

    271
  • Joined

  • Last visited

Everything posted by lional

  1. I understand that but how do I select the days backward. say the date is the 1st of the month, how will I tell it if it is the 31st, 30th etc
  2. Hi All I am writing a site where files are uploaded. I dont want the webspace to be filled with previous images that were uploaded so what I want to do is delete files that were uploaded 2 days ago. I am storing the date of each uploaded file in a mysql database in the form yyyy-mm-dd. How would I accomplish this Regards Lional
  3. Hi I am trying to write a download script that will enable me to download image files from my web server to my local machine. The images are in a mysql table and they are grouped by reference no so there might be more that one image that needs to be downloaded based on the reference number. Each image is assigned a unique upload_id Here is the code for my first script that I pull from mysql baed on the reference number // Query the database $query = "SELECT * FROM attachments WHERE ref_no = '$quo_out'"; $result = mysql_query($query, $conn); while ($row = mysql_fetch_assoc($result)){ $upload_id_out = $row["upload_id"]; $filename_out = $row["filename"]; $filesize_out = $row["filesize"]; // Display the files $final_file_size = ROUND($filesize_out/1024); // Display each record print <<<FILES <td align="left"><a href="download_images.php?uid=$upload_id_out"><font face="arial" size="2" color="white">$filename_out</a></td> <td align="center"><font face="arial" size="2" color="white">$final_file_size kb</td></tr><br> FILES; } and here is my download script $uid_out = $_GET['uid']; include '../includes/conn_db.php'; $query = "SELECT * FROM attachments WHERE upload_id = '13'"; $result = mysql_query($query, $conn); while ($row = mysql_fetch_assoc($result)){ $filename_out = $row["filename"]; $filesize_out = $row["filesize"]; $filetype_out = $row["filetype"]; list ($filename_out, $filesize_out, $filetype_out) = mysql_fetch_row($result); // determine the filename on the server explode('.',$filename_out); // check if the file exists if (file_exists ($filename_out)) { // send the file header ("Content-Type: application/$filetype_out"); header ("Content-disposition: attachment; filename=$filename_out"); header ("Content-Length: $filesize_out"); readfile ($filename_out); $message = '<p>The file has been downloaded.</p>'; } else { $message = '<p><font color="red" size="2" face="arial">The file could not be located on the server.</p>'; } }
  4. Hi all, I need to send two arrays through on my shopping cart. One is for the quantity and the other is if each print is portrait or landscape. Is this possible Here is my code so far <td valign="top"> <font face="arial" size="2" color="white"><input type="text" size="3" name="product[$prod_id_out]" value="0"></td> <td valign="top"> <select name="or[$prod_id_out]"> <option value="Landscape">Landscape</option> <option value="Portrait">Portrait</option> </select> </td> <td><font face="arial" size="2" color="white"> $size_inch_out</td> <td><font face="arial" size="2" color="white">$size_mm_out</td> <td><font face="arial" size="2" color="white">$price_out</td> and my view cart is if (isset($_POST['submit'])) { foreach ($_POST['product'] as $key => $value) { if (($value == 0) AND (is_numeric($value))) { unset ($_SESSION['cart'][$key]); } elseif (is_numeric($value) AND ($value > 0)) { $_SESSION['cart'][$key] = $value; } } foreach ($_POST['or'] as $orkey => $orient) { $_SESSION['orient'][$orkey] = $orient; } } // check if the shopping cart is empty $empty = TRUE; if (isset($_SESSION['cart'])) { foreach($_SESSION['cart'] as $key => $value) { if (isset($value)) { $empty = FALSE; } } } // Display the cart if it is not empty if (!$empty) { include 'includes/conn_db.php'; // Retrieve all of the information for the products in the cart $query = 'SELECT * FROM products WHERE prod_id IN ('; foreach ($_SESSION['cart'] as $key => $value) { $query .= $key . ','; } $query = substr ($query, 0, -1) . ') ORDER BY size_mm ASC'; $result = mysql_query($query); Is this possible
  5. I need to do the quantity and if it is landscape or portrait. This is the code for my products page. <?php include 'includes/conn_db.php'; $query_cl = "SELECT * from products"; $result_cl = mysql_query($query_cl, $conn); while ($row_cl = mysql_fetch_assoc($result_cl)){ $prod_id_out = $row_cl["prod_id"]; $description_out = $row_cl["description"]; $size_inch_out = $row_cl["size_inch"]; $size_mm_out = $row_cl["size_mm"]; $price_out = $row_cl["price"]; print <<<PRICES <tr> <td valign="top"> <font face="arial" size="2" color="white"><input type="text" size="3" name="product[$prod_id_out]" value="0"></td> <td valign="top"> <select name="or[$prod_id_out]"> <option value="Landscape">Landscape</option> <option value="Portrait">Portrait</option> </select> </td> <td><font face="arial" size="2" color="white"> $size_inch_out</td> <td><font face="arial" size="2" color="white">$size_mm_out</td> <td><font face="arial" size="2" color="white">$price_out</td> </tr> PRICES; } ?>[ I have created this page to add it to my cart but I think I have made a mistake if (isset($_POST['submit'])) { foreach ($_POST['product'] as $key => $value) { if (($value == 0) AND (is_numeric($value))) { unset ($_SESSION['cart'][$key]); } elseif (is_numeric($value) AND ($value > 0)) { $_SESSION['cart'][$key] = $value; } } foreach ($_POST['or'] as $key => $orient) { $_SESSION['cart'][$key] = $orient; } } // check if the shopping cart is empty $empty = TRUE; if (isset($_SESSION['cart'])) { foreach($_SESSION['cart'] as $key => $value) { if (isset($value)) { $empty = FALSE; } } } // Display the cart if it is not empty if (!$empty) { include 'includes/conn_db.php'; // Retrieve all of the information for the products in the cart $query = 'SELECT * FROM products WHERE prod_id IN ('; foreach ($_SESSION['cart'] as $key => $value) { $query .= $key . ','; } $query = substr ($query, 0, -1) . ') ORDER BY size_mm ASC'; $result = mysql_query($query);
  6. I have got my array to output the string by doing while($row = mysql_fetch_array($result)){ $a .= '"'. $row['filename'] . '",'; and then to minus the last comma $a = substr($a, 0, -1); The strange thing is that if I say this $files = array($a); I get the following error Warning: fopen("DSC02896.JPG","DSC02869.JPG") [function.fopen]: failed to open stream: Invalid argument in D:\htdocs\cps\confirm.php on line 326 But if I type in $files = array("DSC02896.JPG","DSC02869.JPG") ; Which is just the manual input of the files pulled from the db it works fine. but $files = array("DSC02896.JPG","DSC02869.JPG") ; and $files = array($a); is the same thing or am I wrong any help please
  7. it is still only mailing one attachment Here is my code $query_filename = "SELECT * from attachments WHERE ref_no = '$what_pdf'"; $result_filename = mysql_query($query_filename, $conn); while ($query = mysql_fetch_array(mysql_query("SELECT * FROM attachments WHERE ref_no = '$reference_out'"))) { $a .= '"'.$query['File'].'",'; } $files = array ($a); } // email fields: to, from, subject, and so on $files = array("$files"); $to = $order_mail_out; $from = $email_out; $subject ="Order for Canvas Print Shop Order No. WB$what_pdf"; $message = <<<HERE You have received an order from $fullname_out.<br> To view the complete order click <a href="cps_order.php?quo=$what_pdf" target="_blank">here</a> HERE; $headers = "From: $from"; // boundary $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; // headers for attachment $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; // multipart boundary $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; $message .= "--{$mime_boundary}\n"; // preparing attachments for($x=0;$x<count($files);$x++){ $file = fopen($files[$x],"rb"); $data = fread($file,filesize($files[$x])); fclose($file); $data = chunk_split(base64_encode($data)); $message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$files[$x]\"\n" . "Content-Disposition: attachment;\n" . " filename=\"$files[$x]\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n"; $message .= "--{$mime_boundary}\n"; } // send $ok = @mail($to, $subject, $message, $headers); if ($ok) { $mail_result = "<p>mail sent to $to!</p>"; } else { $mail_result = "<p>mail could not be sent!</p>"; } ?>
  8. Hi I have the following format in a mysql table Ref No File 27 file1.jpg 27 file2.jpg 27 file3.jpg 27 file4.jpg 27 file5.jpg I need to create an array for all ref_no 27 and the array must look like this $files = array("file1.jpg","file2.jpg","file3.jpg","file4.jpg","file5.jpg"); How is this possible
  9. What content-type would I use that would enable me to send attachments and html text in the same mail $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
  10. I have it working, I just need to create the array I mentioned from my table
  11. I am working on solving my own problem. I have a table listing the files uploaded by a reference number. Say my table consists of file1.jpg, file2.jpg, file3.jpg, file4.jpg, and file5.jpg all entries are entered into an attachments table with the same reference number. who will I be able to create the line below $files = array("file1.jpg","file2.jpg","file3.jpg","file4.jpg","file5.jpg"); Thanks
  12. Hi I am trying to create a script where I can send a mail with one or more attachments. The files are all stored in an uploads directory, and each one has an entry in a mysql table. I would like to run the script, have it search for all uploaded files based on a specific reference number and then send it as a mail to a predefined email address attching all the files in one email I wouyld like to pull the filenames from the mysql table Any ideas, or scripts that are already available will be graetly appreciated Thanks Lional
  13. I think the problem is that when I update this foreach($_POST['product'] as $key => $value) sends through 0 values and clears my cart. Is there any way that I can stop this from happening
  14. I have it working almost perfectly except if the page is refreshed I get the following error Warning: Invalid argument supplied for foreach() in D:\htdocs\cps\view_cart.php on line 5 and the quantities and products form ends up blank I am attaching my code: foreach($_POST['product'] as $key => $value) { $qty1 = $value; $pid = $key; if (isset ($_SESSION['cart'][$pid])) { $qty_out = $_SESSION['cart'][$pid] + $qty1; } else { $qty = $qty1; } // add to the cart session variable $_SESSION['cart'][$pid] = $qty; } if (isset($_POST['submit'])) { foreach ($_POST['qty'] as $key => $value) { if (($value == 0) AND (is_numeric($value))) { unset ($_SESSION['cart'][$key]); } elseif (is_numeric($value) AND ($value > 0)) { $_SESSION['cart'][$key] = $value; } } } // check if the shopping cart is empty $empty = TRUE; if (isset($_SESSION['cart'])) { foreach($_SESSION['cart'] as $key => $value) { if (isset($value)) { $empty = FALSE; } } } // Display the cart if it is not empty if (!$empty) { include 'includes/conn_db.php'; // Retrieve all of the information for the products in the cart $query = 'SELECT * FROM products WHERE prod_id IN ('; foreach ($_SESSION['cart'] as $key => $value) { $query .= $key . ','; } $query = substr ($query, 0, -1) . ') ORDER BY size_mm ASC'; $result = mysql_query($query); // create a table and a form print <<<TOP <table width="790" align="center" bgcolor="#b3314b" cellpadding="0" cellspacing="0"> <tr><td height="450"> <table summary="" width="580" align="center" bgcolor="#b3314b"> <tr> <td nowrap align="center"><font face="arial" size="2" color="white"><b>YOUR SHOPPING CART</b></font></tr></table> <table summary="" align="center" width="580" border="1"> <tr> <td> <table border="0" width="580" cellpadding="3"bgcolor="#b3314b"> <tr> <td align="left" width="250"><font face="arial" size="2" color="white"><b>Product</b></font></td> <td align="center" width="70"><font face="arial" size="2" color="white"><b>Qty</b></font></td> <td align="right" width="120"><font face="arial" size="2" color="white"><b>Unit Price</b></font></td> <td align="right" width="120"><font face="arial" size="2" color="white"><b>Line Total</b></font></td> </tr> <form action="view_cart.php" method="post"> TOP; // Print each item $total = 0; // total cost of the order while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { /* if ($row['specials_discount'] > 0) { $list_price_out = $row['price'] / $row['specials_discount']; } else { $list_price_out = $row['price']; } */ $list_price_out = $row['price']; $list_price_out = number_format($list_price_out, 2, '.', ''); // Calculate the total and subtotals $subtotal = $_SESSION['cart'][$row['prod_id']] * $list_price_out; $subtotal = number_format($subtotal, 2, '.', ''); $total += $subtotal; $total = number_format($total, 2, '.', ''); if ($_SESSION['cart'][$row['prod_id']] > 0) { // print the row print <<<ROW <tr> <td align="left"><font face="arial" size="2" color="white">{$row['size_mm']}</font></td> <td align="center"> <input type="text" size="3" name="qty[{$row['prod_id']}]" value="{$_SESSION['cart'][$row['prod_id']]}"></td> <td align="right"><font face="arial" size="2" color="white">R $list_price_out </font></td> <td align="right"><font face="arial" size="2" color="white">R $subtotal</font></td> </tr> ROW; } } // end of the WHILE loop // print the footer and close the table and the form print <<<FOOTER <tr> <td></td><td></td> <td align="right" valign="top"><font face="arial" size="2" color="white"><b>Total:</b></font></td> <td align="right" valign="top"><font face="arial" size="2" color="white"><b>R $total</b></font><br><br></td> </tr> </table> <table width="580" align="center"> <tr><td width="130" align="center"><input type="submit" name="submit" value="Update Cart"></form><form action="checkout.php" method="post"><input type="submit" name="checkout" value="Checkout"></form> </td><td width="85"></td></tr></div> FOOTER;
  15. I was going on what beedie said because I just get garbage on the screen it is not displaying the image and I don't know why.
  16. Thanks This is the first cart I am writing that handles multiple products. How will I retrieve the products on my add to cart page, so that I can view the products in my cart. All my carts have an add to cart by each product Thanks for all your assistance I really appreciate it
  17. Here is an example of my code from my products list. <?php include 'includes/conn_db.php'; $query_cl = "SELECT * from products"; $result_cl = mysql_query($query_cl, $conn); while ($row_cl = mysql_fetch_assoc($result_cl)){ $prod_id_out = $row_cl["prod_id"]; $description_out = $row_cl["description"]; $size_inch_out = $row_cl["size_inch"]; $size_mm_out = $row_cl["size_mm"]; $price_out = $row_cl["price"]; print <<<PRICES <td valign="top"> <select name="$prod_id_out"> <option value="0"></option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select></td> <td> $size_inch_out</td> <td>$size_mm_out</td> <td>$price_out</td> </tr> PRICES; } ?> What I am trying to do is to list each product with a dropdown box for quantities giving options of 1 - 10. And a single order button at the bottom of the screen. so if the customer wants 1 of product 1, 3 of product 4 then both of these products will just be added to the cart with the click of the order button. My problem is that I need to dynamically assign a name for my select statement on the products page , and if the quantity is 1 or more for that particular product, then the product must be added to the shopping cart.
  18. I am fairly new to php and very new to arrays, please give me some poiters so that I can head in the right direction
  19. I am trying to create the expression: $variable = $_POST['$variable']; I am using the following code <?php include 'includes/conn_db.php'; $query_cl = "SELECT * from products"; $result_cl = mysql_query($query_cl, $conn); while ($row_cl = mysql_fetch_assoc($result_cl)){ $prod_id_out = $row_cl["prod_id"]; $description_out = $row_cl["description"]; $size_inch_out = $row_cl["size_inch"]; $size_mm_out = $row_cl["size_mm"]; $price_out = $row_cl["price"]; $post_line = '$$prod_id_out = $_POST["$prod_id_out"];'; eval("$$prod_id_out = $_POST['$prod_id_out'];"); } ?> I am getting the following error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in D:\htdocs\cps\view_cart.php on line 83 What do I need to accomplish this - $variable = $_POST['$variable']; My problem is that I am creating a dynamic product list where a client can purchase more than one product in a single transaction. So I use my product id as the name in my select statement. I therefore need my view cart to be able to evaluate the expression by using the eval function
  20. I have this code on the top of my page ob_flush();ob_start(); header('Content-type: image/jpeg'); session_start();
  21. Hi all I am trying to write a shopping cart that allows for the customer to purchase more than one product in one transaction and then press the buy button. The code on the products list page is: <?php include 'includes/conn_db.php'; $query_cl = "SELECT * from products"; $result_cl = mysql_query($query_cl, $conn); while ($row_cl = mysql_fetch_assoc($result_cl)){ $prod_id_out = $row_cl["prod_id"]; $description_out = $row_cl["description"]; $size_inch_out = $row_cl["size_inch"]; $size_mm_out = $row_cl["size_mm"]; $price_out = $row_cl["price"]; print <<<PRICES <td valign="top"> <select name="$prod_id_out"> <option value="0"></option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select></td> <td> $size_inch_out</td> <td>$size_mm_out</td> <td>$price_out</td> </tr> PRICES; } ?> and my view cart is: <?php include 'includes/conn_db.php'; $query_cl = "SELECT * from products"; $result_cl = mysql_query($query_cl, $conn); while ($row_cl = mysql_fetch_assoc($result_cl)){ $prod_id_out = $row_cl["prod_id"]; $description_out = $row_cl["description"]; $size_inch_out = $row_cl["size_inch"]; $size_mm_out = $row_cl["size_mm"]; $price_out = $row_cl["price"]; $final_var = '$' . $prod_id_out . '_out'; $post_line = $final_var . ' = $_POST["' . $prod_id_out . '"]'; eval("\$post_line = \"$post_line\";"); } ?> I am having problems with the view cart. I need to find a way to dynamically assing the variables and then I want to check if the value is greater than 0, to add the product to the cart Any help will be appreciated
  22. It has been added to the top of my page, still have the same problem
  23. I have tried using this but I get "garbage" printing out instead of my image Here is my code $effects_image = $_SESSION['photo']; list($width, $height) = getimagesize("$effects_image"); $maxWidth = 256; $maxHeight = 256; if ($width > $maxwidth || $height > $maxheight) { //If you haven't specified a max width because you are only constraining the height, then we set the widthDivision as the width of the image. if($maxWidth == ""){ $widthDivision = $width; }else{ //If maxWidth is specified, we set the width division as the maxWidth divide by the width of the image. $widthDivision = $maxWidth/$width; } //Same for height as was said in the width. if($maxHeight == ""){ $heightDivision = $height; }else{ $heightDivision = $maxHeight/$height; } //Now the brains, the min function. Get the lowest number out of the width and height. $MIN = min($widthDivision, $heightDivision); //Now we can set the new widths and height by multiplying the lowest number into both the original width and height. This will constrain the proportions... $newWidth = $MIN*$width; $newHeight = $MIN*$height; }else{ //If the image is fine, just set the new width and height as the default. $newWidth = $width; $newHeight = $height; } // Resample $image_p = imagecreatetruecolor($newWidth, $newHeight); $image = imagecreatefromjpeg($effects_image); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height); // Output imagejpeg($image_p, null, 100);
  24. The image seems to depixulate Any Ideas Thanks Lional
  25. Is there a way to get the dimensions (width and length) of the file we are uploading. The image that gets uploaded will differ depending on the image that the user uploads. I know how to get the file size in Kb or Mb.
×
×
  • 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.