Jump to content
Killersites Forums

Johnny2

Member
  • Content Count

    52
  • Joined

  • Last visited

Everything posted by Johnny2

  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->
  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 ha
  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.
  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
  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 w
  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
  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: H
  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 potent
  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</AccessLi
  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.
  15. Johnny2

    Fixing An Array

    I have this multidimensional array which I'll name "original": $original= array 0 => array 'animal' => 'cats' 'quantity' => 1 1 => array 'animal' => 'dogs' 'quantity' => '1' 2 => array 'animal' => 'cats' 'quantity' => '3' However, I want to merge internal arrays with the same animal to produce this new array: $new= array 0 => array 'animal' => 'cats' 'quantity' => 4 1 => array 'animal' => 'dogs' 'quantity' => '1'
  16. I ended up figuring it out. This works: if($_FILES['img1']['tmp_name'] == ""){}
  17. I am trying to copy a bunch of text which consists of several different paragraphs (with empty space in between them). Then I would like to paste this text into a form's textarea field. When I submit the form I would like to clean the information with something like the preg_replace below. $cleaned_info = preg_replace('#[^A-Za-z0-9)(,\'\.\-!?$" "" "]#i', '', $_POST['info']); How do I preserve the empty lines between paragraphs (which I'm assuming are hard-returns or whatever)? Adding \n to the things which I would like to preserve didn't work.
  18. I have a form with an input field of type="file" name="img1" id="img1". When the form is submitted, I would like to make sure the user selected a file before my script continues. I've tried: if(!isset($_POST['img1'])){ $message="An image file was not selected."; } ...but that isn't working. What am I missing?
  19. Thank you Ben! That was what I was looking for! And I read through the information you linked for me. I have another question now. Let's say you wanted to SELECT * ,let's say 85 columns, of a database table with our query. From what I'm gathering, (and I could be wrong), I would have to type in 85 different variables to bind the results to. $stmt->bind_result(85 separate variables HERE); What a pain in the butt THAT would be... Isn't there an easier way, so that I could SELECT *, but only assign five of them to work with? I mean you can pick and choose which gathered
  20. Yes, but the example you have shown assigns the variable $name with 'test'. You need to store a variable that contains an apostrophe to see what I mean. Such as $name = "Johnny's".
  21. So, let's say you have to work with a variable that has a single quote in it like: $name = "Johnny's Thing"; I figured out how to work with it in mysql by using mysql_real_escape_string(). But how do I work with it in this instance?: $list .= "<a href='editStuff.php?name=$name'>Click Here</a>"; The single quote inside the variable is not allowing it to work correctly. I've tried addslashes(), but that doesn't seem to help. Any suggestions?
  22. I tried using the examples you provided, but those examples were not prepared statements. My new try at the mysqlI statment looks like this: $sex="F"; if ($result = $mysqli->prepare("SELECT * FROM friends WHERE sex = ?")){ $result->bind_param("s", $sex); $result->execute(); $result->store_result(); if ($result->num_rows != 0){ while ($row = $result->fetch_object()){ $name = $row->name; $age = $row->age; $favoriteColor = $row->favoriteColor; $list .= "Here is the result->num_rows: ".$result->num_rows."<br />Here is name:
  23. Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, object given This is referring to the if-statement area (of the mysqlI version)
  24. //I would like to convert this mysql code to a mysqlI version: $sql=mysql_query("SELECT * FROM friends WHERE sex = 'F'"); $friendCount = mysql_num_rows($sql); if ($friendCount > 0) { while($row = mysql_fetch_array($sql)){ $name = $row["name"]; $age = $row["age"]; $favoriteColor = $row["favoriteColor"]; $list1 .= "Here is the name: ".$name."<br />Here is age: ".$age."<br />Here is the favorite color: ".$favoriteColor."<br /><br />"; } } //Here is my shot at the mysqlI version: $sex="F";
×
×
  • Create New...