Jump to content
Killersites Forums


  • Posts

  • Joined

  • Last visited

About Johnny2

  • Birthday August 14

Profile Information

  • Gender
  • Location
  • Interests
    Backpacking, Camping, Snowshoeing, Snorkeling, Boardgames, Learning Web-Design & Web-Programming.

Johnny2's Achievements


Newbie (1/14)



  1. My PHP script for mysqli queries works most of the time, but while running a loop that queries database many times, occasionally I'll get Warning: PHP Warning: mysqli_stmt::execute(): (HY000/2013): Lost connection to MySQL server during query in... blah blah blah Can someone tell me if I need to modify the structure of my queries to make it work better? Here's my example: <?php $host = "localhost"; $username = "blah_blah"; $password = "blah_blah"; $database = "blah_blah"; $mysqli = new mysqli($host, $username, $password, $database,0,'/var/lib/mysql/mysql.sock'); $mysqli->set_charset('utf8'); if ($stmt = $mysqli->prepare("SELECT column_A FROM table_X WHERE column_B=? AND column_C=? LIMIT 1")){ $stmt->bind_param("si", $value_1, $value_2); $stmt->execute(); $stmt->bind_result($column_A_value); $stmt->fetch(); $stmt->close(); } ?>
  2. It's not always 21 seconds. It can be as low as 2 seconds if a bunch of info doesn't have to be gotten from databases for the particular user. But for the users that need more information gathered, I wanted a loading message to display.
  3. Right when my user logs in, the login.php file sends them to another file (we'll call it File_2) which takes about 21 seconds to load... so the user is staring at the filled-in login form for 21 seconds before they see anything else happen. After the user clicks the login button, I'd like to display something to the user which indicates the page is loading. At the end of "File_2", after it is all finished gathering data, it displays the html. I'm having difficulty figuring out how to display a "loading" message while the user waits. Any help would be appreciated. I've tried having the user sent from the login.php file to "File_1" THEN to "File_2", but this didn't work. It had the same effect as if the user was sent from login.php directly to "File_2". Code I've used: In login.php file: // After the user is granted permission to login: header("Location: File_1.php"); exit; File_1 (where I was trying to show the user "Page is Loading", while they waited: <?php session_start(); ?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>Loading</title> </head> <body> <h1>The Page is Loading. This may take a few moments.</h1> </body> </html> <?php header("Location: File_2.php"); exit; ?> Then File_2 is just the page that loads, but the user doesn't see anything happen for 21 seconds.
  4. I'm using the following code to save a file from a form: <?php $item_ID=53; // ADDS IMAGES TO IMAGES FOLDER $image_name_1 = "$item_ID"."_img1".".jpg"; //Saves newly-named image file move_uploaded_file($_FILES['img1']['tmp_name'],"../images/$image_name_1"); ?> The code works great. However; some files become turned on their side when viewed on the website. I'm taking a shot in the dark and thinking it has something to do with the way Windows 8 saves the file. Because if I take the same file and re-save it in photoshop, then upload that file, it is not turned on it's side. Anyway, I cannot alter the code of windows, so is there some php code that I can use to make sure the image isn't turned on it's side when uploaded via my script? Thanks.
  5. I need to create a hyperlink that produces the exact same effect as: 1. clicking the browser's back button 2. then clicking "Try Again" 3. and then clicking "Resend" (see images below). PHP is preferred. (or javascript that I can echo with PHP) Thank you
  6. Is there a quick and easy way to get a webpage's banner image to load BEFORE the webpage displays itself to the browser? I have a page that displays, then a quarter of a second later the main image displays itself. This causes things to jump around and makes it seem a little glitchy. Thanks.
  7. Hello, I can't figure out a few lines of cURL code. I have 3 files involved... File #1 will have a form that submits the form data (via POST) to FILE #2. File #2 receives the POST, automatically re-posts the exact same data to File #3, then continues to process some of the info the POST contained. File #3 receives the POST from File #2, and processes it normally (and this is where the USER should end up). What I can't figure out is the part (in file #2) that receives the POST then AUTOMATICALLY REPOSTS it. The cURL code that I have to work with doesn't seem to work so far. Here's what I have to work with: $url='File_number_3'; //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_POST,count($_POST)); curl_setopt($ch,CURLOPT_POSTFIELDS,$_POST); //execute post $result = curl_exec($ch); //close connection curl_close($ch); Anyone know what I need to do with this code to simply get it to take the incoming POST, then re-submit it to File_number_3 ? Thanks
  8. I have this multidimensional array that I'll call "$Items_Array": array (size=3) 0 => array (size=3) 'id' => string '1' (length=1) 'quantity' => int 1 'name' => string 'Book' (length=1) 1 => array (size=3) 'id' => string '2' (length=1) 'quantity' => int 5 'name' => string 'Shirt' (length=29) 2 => array (size=3) 'id' => string '3' (length=1) 'quantity' => int 2 'name' => string 'Ice-cream' (length=22) I want to re-arrange the order of elements, according to "quantity", so that the one with the largest quantity comes first. The desired result would look like this: array (size=3) 0 => array (size=3) 'id' => string '2' (length=1) 'quantity' => int 5 'name' => string 'Shirt' (length=29) 1 => array (size=3) 'id' => string '3' (length=1) 'quantity' => int 2 'name' => string 'Ice-cream' (length=22) 2 => array (size=3) 'id' => string '1' (length=1) 'quantity' => int 1 'name' => string 'Book' (length=1) Can someone show me how to do this? Is it just an easy PHP command?
  9. I have 2 questions about the basic understanding of website security. #1: Once I have my website built, get it hosted, and I'm ready to go live, how do I go about making sure my website Security is up to par? Are there website security companies that try to hack into your site and find security holes, then report to you what you need to fix? At that point, how do I get the repairs done if I'm a non-expert? #2: How do I become PCI Compliant (so I can take credit cards and whatnot)? Do I just call up some PCI Compliance company and have them analyze my website, then they tell me what to fix? At that point, how do I get the repairs done if I'm a non-expert? Thanks
  10. Thanks for your input Eddie. Let's say your website files & folders are supposed to go inside this made-up directory/folder: 123.456.78.90/public_html (this is kind of what the directory looks like when I'm in my c-panel anyways) Are you saying that I should put most of my website files in this public_html folder, but put data I want to protect into a different folder which is on the same level as the public_html folder? Like here: 123.456.78.90/_data If I'm correct, would you put files such as config files here (which may contain password info)? Question #2: How does this relate to session info (like session variables that I don't want hackers to get their hands on)?
  11. Hi All, I've come across some PHP website-building literature that stated: "For sensitive data being stored, but not stored in a database, change your sessions directory, and use the Web root directory's parent folder" I understand that no one here is the author, but could someone take a guess at and explain what this means? I'm not sure what a sessions directory is. When it refers to "sessions", is it talking about session variables that we can create?... like if I wanted to store the logged-in user's first name in $_SESSION['userFirstName']? Is temporarily storing potentially sensitive data in session variables not secure? I'm pretty new at this, so please use plenty of laymen terms Thank you so much!
  12. Thanks Ben. Do you know of any tutorial videos on parsing XML or API's?
  13. I was just wondering if I could get a short & sweet explanation for how to exchange data with other websites. A common example would be requesting the shipping-cost for a package from UPS. I'm pretty fuzzy with how one "catches" the data replied to you (from UPS), and how you would get that data put into a PHP variable. Once this "answer" to my request is in a PHP variable, I would be able to figure it out from there. Their example code for a request: <?xml version="1.0"?> <AccessRequest xml:lang="en-US"> <AccessLicenseNumber>Your_License</AccessLicenseNumber> <UserId>Your_ID</UserId> <Password>Your_Password</Password> </AccessRequest> <?xml version="1.0"?> <RatingServiceSelectionRequest xml:lang="en-US"> <Request> <TransactionReference> <CustomerContext>Rating and Service</CustomerContext> <XpciVersion>1.0</XpciVersion> </TransactionReference> <RequestAction>Rate</RequestAction> <RequestOption>Rate</RequestOption> </Request> <PickupType> <code>07</code> <Description>Rate</Description> </PickupType> <Shipment> <Description>Rate Description</Description> <Shipper> <Name>Name</Name> <PhoneNumber>1234567890</PhoneNumber> <ShipperNumber>Ship Number</ShipperNumber> <address> <AddressLine1>Address Line</AddressLine1> <City>City</City> <StateProvinceCode>NJ</StateProvinceCode> <PostalCode>07430</PostalCode> <CountryCode>US</CountryCode> </address> </Shipper> <ShipTo> <CompanyName>Company Name</CompanyName> <PhoneNumber>1234567890</PhoneNumber> <address> <AddressLine1>Address Line</AddressLine1> <City>Corado</City> <PostalCode>00646</PostalCode> <CountryCode>PR</CountryCode> </address> </ShipTo> <ShipFrom> <CompanyName>Company Name</CompanyName> <AttentionName>Attention Name</AttentionName> <PhoneNumber>1234567890</PhoneNumber> <FaxNumber>1234567890</FaxNumber> <address> <AddressLine1>Address Line</AddressLine1> <City>Boca Raton</City> <StateProvinceCode>FL</StateProvinceCode> <PostalCode>33434</PostalCode> <CountryCode>US</CountryCode> </address> </ShipFrom> <Service> <code>03</code> </Service> <PaymentInformation> <Prepaid> <BillShipper> <AccountNumber>Ship Number</AccountNumber> </BillShipper> </Prepaid> </PaymentInformation> <Package> <PackagingType> <code>02</code> <Description>Customer Supplied</Description> </PackagingType> <Description>Rate</Description> <PackageWeight> <UnitOfMeasurement> <code>LBS</code> </UnitOfMeasurement> <Weight>10</Weight> </PackageWeight> </Package> <ShipmentServiceOptions> <OnCallAir> <Schedule> <PickupDay>02</PickupDay> <Method>02</Method> </Schedule> </OnCallAir> </ShipmentServiceOptions> </Shipment> </RatingServiceSelectionRequest> Their example of a Response (I have no idea how I would even get or work with this) <?xml version="1.0" encoding="ISO-8859-1"?> <RatingServiceSelectionResponse> <Response> <TransactionReference> <CustomerContext>Rating and Service</CustomerContext> <XpciVersion>1.0</XpciVersion> </TransactionReference> <ResponseStatusCode>1</ResponseStatusCode> <ResponseStatusDescription>Success</ResponseStatusDescription> </Response> <RatedShipment> <Service> <Code>03</Code> </Service> <RatedShipmentWarning>Your invoice may vary from the displayed reference rates</RatedShipmentWarning> <BillingWeight> <UnitOfMeasurement> <Code>LBS</Code> </UnitOfMeasurement> <Weight>10.0</Weight> </BillingWeight> <TransportationCharges> <CurrencyCode>USD</CurrencyCode> <MonetaryValue>52.16</MonetaryValue> </TransportationCharges> <ServiceOptionsCharges> <CurrencyCode>USD</CurrencyCode> <MonetaryValue>0.00</MonetaryValue> </ServiceOptionsCharges> <TotalCharges> <CurrencyCode>USD</CurrencyCode> <MonetaryValue>52.16</MonetaryValue> </TotalCharges> <GuaranteedDaysToDelivery/> <ScheduledDeliveryTime/> <RatedPackage> <TransportationCharges> <CurrencyCode>USD</CurrencyCode> <MonetaryValue>52.16</MonetaryValue> </TransportationCharges> <ServiceOptionsCharges> <CurrencyCode>USD</CurrencyCode> <MonetaryValue>0.00</MonetaryValue> </ServiceOptionsCharges> <TotalCharges> <CurrencyCode>USD</CurrencyCode> <MonetaryValue>52.16</MonetaryValue> </TotalCharges> <Weight>10.0</Weight> <BillingWeight> <UnitOfMeasurement> <Code>LBS</Code> </UnitOfMeasurement> <Weight>10.0</Weight> </BillingWeight> </RatedPackage> </RatedShipment> </RatingServiceSelectionResponse> Any feedback would be appreciated Thank you!
  14. Johnny2

    Fixing An Array

    Thank you very much Ben! The fixed worked well. I figured out the rest from there. Sorry it took so long to respond. I believe I got distracted when I last read your feedback.
  • Create New...