Jump to content

123guy

Members
  • Posts

    38
  • Joined

  • Last visited

Everything posted by 123guy

  1. it still displays all in one line with no breaks. <TrackResponse><TrackInfo ID="EJ958088694US"><TrackSummary>Your item was delivered at 1:39 pm on June 1 in WOBURN MA 01815.</TrackSummary><TrackDetail>May 30 7:44 am NOTICE LEFT WOBURN MA 01815.</TrackDetail><TrackDetail>May 30 7:36 am ARRIVAL AT UNIT NORTH READING MA 01889.</TrackDetail><TrackDetail>May 29 6:00 pm ACCEPT OR PICKUP PORTSMOUTH NH 03801.</TrackDetail></TrackInfo></TrackResponse>
  2. yes I have, the issue is, I don't know how I call the server. I am getting very confused on how you use the url they gave you. I found this code here: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <?php //enter your username and password $data_string ='API=TrackV2&XML=<TrackRequest USERID="xxx"><TrackID ID="EJ958088694US"></TrackID></TrackRequest>'; // Get a CURL handle // Tell CURL the URL of the recipient script $curl_handle = curl_init (); curl_setopt ($curl_handle, CURLOPT_URL, 'http://testing.shippingapis.com/ShippingAPITest.dll'); // This section sets various options. See http://www.php.net/manual/en/function.curl-setopt.php curl_setopt ($curl_handle, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($curl_handle, CURLOPT_POST, 1); curl_setopt ($curl_handle, CURLOPT_POSTFIELDS, $data_string); // Perform the POST and get the data returned by the server. $result = curl_exec ($curl_handle) or die ("There has been a CURL_EXEC error"); // Close the CURL handle curl_close ($curl_handle); echo $result; ?> </head> <body> </body> </html> but on this everything displays on the same line. Maybe this one will work, but I need it to display correctly. it looks like this right now Your item was delivered at 1:39 pm on June 1 in WOBURN MA 01815.May 30 7:44 am NOTICE LEFT WOBURN MA 01815.May 30 7:36 am ARRIVAL AT UNIT NORTH READING MA 01889.May 29 6:00 pm ACCEPT OR PICKUP PORTSMOUTH NH 03801.
  3. I am trying to integrate USPS Tracking info into my website. I have obtained a web tools user id from them...but I need to know how I send the request to the server and back to the site via php. Can any one help me out with this by providing some code, or by posting a good link to get me started? thanks
  4. btw, this is the code I have modified a bit: <?php // upload the file if (isset($_POST["submit"])){ // index.php function generate_resized_image(){ $max_dimension = 600; // Max new width or height, can not exceed this value. $dir = "../images/"; // Directory to save resized image. (Include a trailing slash - /) // Collect the post variables. $postvars = array( "image" => trim($_FILES["image"]["name"]), "image_tmp" => $_FILES["image"]["tmp_name"], "image_size" => (int)$_FILES["image"]["size"], "image_max_width" => (int)$_POST["image_max_width"], "image_max_height" => (int)$_POST["image_max_height"] ); // Array of valid extensions. $valid_exts = array("jpg","jpeg","gif","png"); // Select the extension from the file. $ext = end(explode(".",strtolower(trim($_FILES["image"]["name"])))); // Check not larger than 175kb. if($postvars["image_size"] <= 100000000000000000000){ // Check is valid extension. if(in_array($ext,$valid_exts)){ if($ext == "jpg" || $ext == "jpeg"){ $image = imagecreatefromjpeg($postvars["image_tmp"]); } else if($ext == "gif"){ $image = imagecreatefromgif($postvars["image_tmp"]); } else if($ext == "png"){ $image = imagecreatefrompng($postvars["image_tmp"]); } // Grab the width and height of the image. list($width,$height) = getimagesize($postvars["image_tmp"]); // If the max width input is greater than max height we base the new image off of that, otherwise we // use the max height input. // We get the other dimension by multiplying the quotient of the new width or height divided by // the old width or height. if($postvars["image_max_width"] > $postvars["image_max_height"]){ if($postvars["image_max_width"] > $max_dimension){ $newwidth = $max_dimension; } else { $newwidth = $postvars["image_max_width"]; } $newheight = ($newwidth / $width) * $height; } else { if($postvars["image_max_height"] > $max_dimension){ $newheight = $max_dimension; } else { $newheight = $postvars["image_max_height"]; } $newwidth = ($newheight / $height) * $width; } // Create temporary image file. $tmp = imagecreatetruecolor($newwidth,$newheight); // Copy the image to one with the new width and height. imagecopyresampled($tmp,$image,0,0,0,0,$newwidth,$newheight,$width,$height); // Create random 4 digit number for filename. $rand = rand(1000,9999); $filename = $dir.$rand.$postvars["image"]; // Create image file with 100% quality. imagejpeg($tmp,$filename,100); return "<strong>Image Preview:</strong><br/> <img src=\"".$filename."\" border=\"0\" title=\"Resized Image Preview\" style=\"padding: 4px 0px 4px 0px;background-color:#e0e0e0\" /><br/> Resized image successfully generated. <a href=\"".$filename."\" target=\"_blank\" name=\"Download your resized image now!\">Click here to download your image.</a>"; imagedestroy($image); imagedestroy($tmp); } else { return "File size too large. Max allowed file size is ."; } } else { return "Invalid file type. You must upload an image file. (jpg, jpeg, gif, png)."; } } mysql_query("INSERT INTO images (item_id, image) VALUES ('$id123', 'images/".$remote_file1."')"); $title = $_POST['title']; $des = mysql_real_escape_string($_POST['description']); $price = mysql_real_escape_string($_POST['price']); $qty = mysql_real_escape_string($_POST['quantity']); $cat2 = mysql_real_escape_string($_POST['category2']); $cat = mysql_real_escape_string($_POST['category']); if ($cat2 !='') {$cat = $cat2; } mysql_query("INSERT INTO items (id, name, price, description, quantity, category_id, image) VALUES ('$id123', '$title', '$price','$des', '$qty', '$cat', 'images/".$remote_file1."')"); if($cat2 !=''){ mysql_query("INSERT INTO categories (category) VALUES ('$cat2')"); exit; } } ?> <form action="newprod.php?do=upload" method="post" enctype="multipart/form-data" name="form1"> <table width="0" border="0" cellspacing="2" cellpadding="2"> <tr> <td width="69"> <tr> <td>Name:</td> <td width="301"><div align="left"> <input name="title" type="text" /> </div></td> </tr> <tr> <td>Price:</td> <td><div align="left"><input name="price" type="text" /></div></td> </tr> <tr> <td>Quantity:</td> <td><div align="left"><input name="quantity" type="text" /></div></td> </tr> <tr> <td>Description:</td> <td><div align="left"><textarea name="description" cols="" rows=""></textarea></div></td> </tr> <tr> <td>Main Picture:</td> <td> <input name="file1[]" type="file" /></td> </tr> <tr> <td>Picture:</td> <td> <input name="image" type="file" multiple="multiple" /></td> </tr> <tr> <td>Category:</td> <td><div align="left"> <label for="category"></label> <select name="category" id="category"> <option value="">---Choose Category---</option> <?php $result = mysql_query("SELECT * FROM categories"); while($row = mysql_fetch_array($result)) { $category = $row['category']; $id = $row['id']; ?> <option value="<?php echo $category; ?>"><?php echo $category; ?></option> <?php } ?> </select> <br /> or make new category (leave blank if option is already selected):<br /> <label for="category2"></label> <input type="text" name="category2" id="category2" /> </td> </tr> <tr> <td> </td> <input name="image_max_width" type="hidden" id="image_max_width" value="600" size="4"> <input name="image_max_height" type="hidden" id="image_max_height" value="1000000" size="4"> </td> </tr> <tr> <td> </td> <td><div align="left"><input type="submit" name="submit" id="submit" value="Save" /></div></td> </tr> </table> </form> <?php if(isset($_GET['do']) && $_GET['do'] == "upload") { $upload_and_resize = generate_resized_image(); echo '<div id="upload">'. $upload_and_resize. '</div>'; } ?> I know I will need to change image to image[](right?). can anyone help me out with this?
  5. Ok, I was just never able to find anything that worked...I didn't realize I had the GD library until I found a code to test it out. any ways, I want this code from this website: http://bgallz.org/502/php-upload-resize-image/ but I need to know how I can do a foreach for the images...it says can't redeclare...how would I do this as a foreach...or at least able to save more than one file. thanks in advance
  6. I guess even if it isn't resized, but there is a way to make the file size smaller, that could work too...but I don't think thats possible
  7. hello. I am trying to find a code that will resize an image to 600px wide, with the height scaling to it. I have been google this for awhile, but all I can find is info on how to display it as a different size. I need to be able to upload from a foreach loop, multiple images, with a smaller image....so that it saves as a smaller file size. so lets say the original is a 60" X 60"....I want my code to scale it down to a 10" X 10"(for example). I need it so that when uploaded, the file size is smaller as to allow the image to load faster. I don't think this makes much sense, but if it does, could you help me out with this?
  8. ok, thanks, how do I display the message though? I would still like all the products to display, but I want the button to change to my message. My table structures are items: id, product, price, etc cart: id, product_id, price, etc. having never worked with joins, I am not sure what I should change to fit what....in the query. could you help me with these?
  9. ok, so the goal is to have one query run that pulls products out of my database and duplicates divs to display these in....this works fine. I then need to run another query for each of the products that were just pulled and see if the current session has the products in the cart. The cart is stored in a database. If the cart already has that product, I would like a message to display, "go to cart to change quantity"....if it is not present in the cart, then it shows an add to cart button. does this make a little more sense?
  10. what is the best way to do this? I have read about joins, but I am not really sure how they work or if this is the best situation for one. Any help?
  11. Hi all. Question for you. I am setting up a shopping cart and I would like the main page to have divs set aside to showcase products and allow for a quick add to cart. I only want the customer to be able to quick add one so that they don't go over the max limit on accident. on the checkout page, I have it where they can change the quantity, but I have form validation set up so that it can't go over max quantity. So my question is, how do I run a loop that selects the products, then another query finds out whether that product is in the cart already or not. there is a max of four products on the home screen. this is what I have so far. <?php $result = mysql_query("SELECT * FROM items order by quantity ASC LIMIT 4"); $i = 0; echo " <table cellspacing='20px' border='10' frame='void' ><tr>"; while($row = mysql_fetch_array($result)) { $title = $row['name']; $id = $row['id']; $price = $row['price']; $image = $row['image']; $qty = $row['quantity']; echo "<td valign='top' style='border-radius:20px' width='150'bgcolor='#CBE8F9'>"; ?> </p> <a href="product.php?id=<?php echo $id; ?>"> <center><img src="<?php echo $image; ?>" width="140" /></center><br> <?php echo $title; ?><br /> <font color="red"><?php setlocale(LC_MONETARY, "en_US"); echo money_format("%n", $price);?></font></a><br /> <form action="addtocart.php" method="post"><input name="product" type="hidden" value="<?php echo $title; ?>" /><input name="price" type="hidden" value="<?php echo $price; ?>" /><input name="id" type="hidden" value="<?php echo $id; ?>" /><input name="qty" type="hidden" value="1" /><input type="hidden" name="image" value="<?php echo $image; ?>" /><?php $result1 = mysql_query("SELECT * FROM cart where cart='".session_id()."' AND product_id='".$id."' AND qty !='0'"); while($row1 = mysql_fetch_array($result1)) { $qty=$row1['qty']; if(!$result){ ?><input name="submit" type="submit" value="Add To Cart" /><?php } if($result){echo 'Item is already in cart, you may change the quantity there';}} ?></form></div> <?php echo "</td>"; if ($i && $i%6 == 5) echo '</tr><tr>'; $i++; } echo "</table> "; ?> but obviously it's not working, that's why I am here. It currently says all products are in cart and it also runs the query for the 2nd product 2 times. any help on this?
  12. thanks! that is what I needed! one other question, is there any way to also make it so that when I pull it from the database it is able to sense line breaks or new paragraphs? I use a text area for user to input value, and database shows when and where the pressed the "return" key, but when I then pull it from the database, it does not show that the return key was pushed. how can I make it so that it shows up exactly how the user entered it?
  13. is there a way to automatically replace all characters inside of a posted variable that could end query? the variable could be something such as $_POST['item'] being "the dog is 12" long". I need the " after 12 to be replaced with it's code so that the query doesn't end after 12. I know I could use str_replace to do it, but I was wondering if there is any way I could do this for all characters that may happen to interfere with the query. Sorry if this is an obvious answer, but I am pretty new to php. what is the easiest way to do this?
×
×
  • 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.