-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
"3 times the requirements" is a loaded statement though. 9 little things can take the same time as 3 big things. Again, I can't judge since I don't know the details but the best thing you can do to ensure you're getting a fair price is to get multiple quotes.
-
I'm curious about how the cost estimate is much higher because of this.. it's a legitimate request, but it doesn't sound like you're being given a legitimate estimate. But then, I haven't seen your site, so take that for what it's worth.
-
pfft... I know every dirty little secret. I even know who leaves the magazines sticky in the employee bathroom. I KNOW.
-
go to github. find something that interests you. fork it. make it harder faster better stronger.
- 3 replies
-
- php
- javascript
-
(and 2 more)
Tagged with:
-
well that's not really replacing the width and height.. it's removing it.
-
unzip file with extractTo results in owner problem
.josh replied to flyingdutchman's topic in PHP Coding Help
You would need to logon via SSH (not ftp) to execute php on the command line and if you get that far, you may as well just skip the php file and unzip the file yourself via command line. That's because php.exe isn't a core program that comes on computers. It's a program you download and install like any other program. It just so happens that most hosting providers out there install it on their server because it's a popular choice for making web based scripts. If you want to poke at it on your own computer, I suggest you try WAMP or XAMPP. -
but +1 for being honest about your intentions, so for that I'll vaguely point you in the right direction. Basically in order to achieve this, you'll have to make an app to be installed on her phone (like a java app) and you'll have to get her to install it and it has to be running. And the app (possibly, I'm not sure on this point) has to have root access which means the phone will need to be jailbroken.
-
"But..I learned it by watching the NSA..."
-
Fair enough. To an extent I will agree with the "guns don't kill people, people kill people" argument. But I counter that with: nobody cuts veggies with a sword, and if you claim you do, you can't fault me for calling you a liar.
-
also, are you sure it doesn't work? I added an accent pillow and a scarf and the image shows both items and when i print, it shows both items. Perhaps it's just bad logic or typo for one of the specific items?
-
you need to show some actual (relevant) code that creates the image.
-
you probably aren't filling out one of your form fields, so there's no one or more $_POST['whicheveroneyoudidnotfillouthere'] indexes. If not that, then check that your form method is POST and not GET
-
you're making this harder than it needs to be. First, you're using a loop with fetch to put columns into 3 separate arrays. This is terrible for 2 reasons. First is that now you have to pass around 3 separate arrays instead of just one multi-dim array. Second, now you will almost certainly never need to make use of just the names or just the lastnames or just the emails. Instead, you will almost certainly be using a loop to have the data grouped by it's original row. IOW you've flipped the rows and columns for no practical reason. You should put it to an array that looks something like this: array( 0 => array('email'=>'email address','name'=>'some name','lastname'=>'last name here'), 1 => array('email'=>'email address','name'=>'some name','lastname'=>'last name here'), 2 => array('email'=>'email address','name'=>'some name','lastname'=>'last name here'), // etc.. ) That way you can easily reference a single set. Examples: echo first row: echo $array[0]['email']; echo all emails: foreach ($array as $row) { echo $row['email']; } Which brings me back to your original use of fetch() and the while loop. All you need to do is use $data = $qstmt->fetchAll(PDO::FETCH_ASSOC); And then $data will be structured exactly as above. No loop or assigning it to other vars or nothing. That is the exact point of fetchAll: when you want to grab all the returned results and pass it somewhere else.
-
It's a warning because all your script does is declare $this->form_data as *a* property of your class/object, but doesn't initialize it as any particular type (specifically, some object type, since that's what you are using it as). Then in your function, you just start using it as an assumed object. It's basically the equivalent of doing $array['someindex'] = 'foobar'; without first doing $array = array();. PHP is generally smart enough to assume your intentions based on context, but it will throw a warning at you about it if your error reporting is turned on to show it. At a minimum, you should do this: $this->form_data = new stdClass(); // init as a generic object $this->form_data->title = ''; // etc... Or this: $this->form_data = (object) array( 'title' => '', 'first_name' => '', // etc.. ); Those will initialize $this->form_data as a generic/anonymous object type and keep the error from happening. HOWEVER.. $this->form_data may or may not really supposed to be instantiated as some existing class in your framework (I can't answer that). If your script seems to be working fine, aside from that warning being shown, then it's probably safe to just initialize it as shown above.
-
You need to use $query->fetch() or $query->fetchAll() or similar.
-
unzip file with extractTo results in owner problem
.josh replied to flyingdutchman's topic in PHP Coding Help
AFAIK there's no zipArchive method/arg that will automatically do that, but php does have chown chgrp and chmod functions that you could use after the extraction. -
in any case, i'm not sure how useful that seeing that file will really be. Sure, that's the file the actual error is happening in, but chances are there's probably a different file that has config info and you have some kind of path setting wrong.
-
Basically all your questions seem to boil down to "How do I paginate my data?" to which the summed up answer this this: read the tutorial links I gave you, or google "php pagination tutorial" if you wanna look for some up-to-date coding examples (again, as I mentioned before, the principle is timeless, but the code in the links I gave you is out of date). IOW Pagination encompasses virtually all of the functionality you're looking to do.
-
You'd build pagination links. Usually people have them somewhere at the top and bottom of all the data that's echoed out. And usually people do it with links that look similar to this: "First Prev 2 3 [4] 5 6 Next Last" Where there's links to go to first and last page, next and previous, and some links to go to a couple pages around the the current page. There is an example of how to do this in the pagination tutorial link I gave you, and virtually any other "pagination" tutorial out there will demonstrate this, and virtually any script you find out there will include it, as it's one of the signature features of a pagination.
-
Okay, let's summarize (again): Based on your (implied) requirements, your solution won't work. 1) Your original post implied that within a given string, there could be duplication of characters. But your current solution doesn't do this either. This was the original problem I had with your solution. 2) You have implied that each row must have a unique string, and your solution does not guarantee doing that. 3) You've also implied in your original post that you want the strings to be 11 chars long with a certain set of characters. Your current solution doesn't guarantee doing this either. Your code fails on all 3 of these implied requirements, because all it does is grab (up to) an 11 char substring within your base string, based on a random offset. So, 1) Your original post had code that picks a random position in your base string 11 times. This gave you an 11 char long random string every time. However, since you had it picking from the same pool every time, it was possible that within that 11 char string, the same character could come up more than once. Overall, I'm getting the impression that you don't actually care about this, as long as the string as a whole is unique for all rows. But on that note... 2) At most, there will only be 65 different string combinations generated from your code, because there are only 65 positions in your base string, for your substring position to start at. So it is impossible to generate 1000 strings and not get duplicates. Check your table. You will see duplicates. 3) You pick a random number and use that as the offset for substring. Your base string is 65 chars long. If the random number generated for the offset is say, 60, then you're going to end up with a 5 char long string. This is why you see strings shorter than 11 chars in Barand's example, and if you look in your own table, you will likely see this as well. If you don't, then that's sheer luck, since there's only 54 combinations that will have a full 11 chars. In short, your "combinations" aren't really combinations at all, nor are they unique by any means. They are simply substrings within your base string. So you have implied 2 requirements (I'm only counting #2 and #3 above, since I don't think you really care about #1): 1) that the string be unique for each row 2) that the string have 11 chars and use the following characters: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-_' So the question I have asked you (many times now), is whether or not you really care about requirement #2. If all you really care about is requirement #1 being fulfilled, then all you need to do is use UUID() as the generated random string. You don't need a base string that lists all the letters and numbers out; nothing. UUID() will generate a string that looks something like this: 6ccd780c-baba-1026-9564-0040f4311e29. And it will be a unique string every time it's called. And you can continue to use this for future rows and not worry about or check for collision, because it is a time-based id. It's that simple. But the caveats of using UUID() is that a) it doesn't fulfill your implied 11 char string requirement, and b) it doesn't incorporate some of the characters you list in your base string. If you are fine with this, then use UUID() and you are done.. If, however, you really want to stick with using your base characters and have 11 char long strings, things will be significantly more complex. You will have to have code that looks like this (pseudocode) $c='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-_'; /* TODO: write some code to select all row ids from database.. your table does have an id row acting as primary key / index, right? put them into an array called $rowIDs */ // generate a random string for each one, using logic to make sure there are no duplicates generated $numRows = count($rowIDs); $randomStrings = array(); while ( count($randomStrings) < $numRows ) { $randstr=''; for ($x=0;$x<10;$x++) $randstr.=$c{rand(0,strlen($c)-1)}; if ( !in_array($randstr,$randomStrings) $randomStrings[] = $randstr; } /* TODO: Now we have an array $randomStrings that has as many unique ids as there are rows. They are all 11 chars long, using your specified char pool Now you need to update each row individually */ foreach ($rowIDs as $key => $id) { dbquery("UPDATE ".POST." SET post_url = '{$randomStrings[$key]}' WHERE id = '{$id}'" ); } So you will have to fill in the blanks on some of that, but that's the principle. But this only solves for updating what's in there NOW. What happens if you have more columns in the future? You will basically need to have code that generates an id string like above, but put it in a loop that keeps generating until it generates one that isn't a duplicate of what's already in there. Therefore, clearly the best, simplest route forward is to use UUID(). Use UUID(). Do it. You know what would be great? If there was some sort of built-in sql function that will generate a unique id. Oh wait, there is: UUID(). You cannot resist the power of the UUIDarkside. DO IT.
-
PHP mail() form sends emails with blank variables
.josh replied to dandymandy's topic in PHP Coding Help
remove enctype="text/plain" -
This post right here, the one I've posted and quoted twice now:
-
I posted 2 potential solutions. One is a really easy solution, if you're willing to change up the string length/format. Read my posts.
-
rename it to .txt. You know.. it's likely it's just a plaintext file and your framework just uses .zend as a convention. IOW you can probably just open it in a regular text editor.
-
Right, it does update all the rows, and it seems like they are different strings if you just glance at it, and it's possible that they may in fact be unique strings. However, it's possible that this code will generate duplicate strings. If you don't believe me, run a query that selects for duplicate strings. Then run that query above again and then select query again. Wash rinse repeat and you will eventually get dupes. A more practical test would be to reduce the number of available characters and watch what happens.