
teynon
Members-
Posts
898 -
Joined
-
Last visited
-
Days Won
1
Everything posted by teynon
-
I know, i'm just kidding. 20 feet is like 4 people tall
-
You die from 20 feet? I could see getting hurt, perhaps.
-
PHP 5.4 supports what you are trying to do. PHP 5.3 and prior do not support using a function's return value like that. Your server is probably on a different PHP version than your localhost. http://php.net/manual/en/language.types.array.php#example-88
-
Only variables should be passed by reference
teynon replied to tobimichigan's topic in PHP Coding Help
I actually posted the wrong answer the first time. end moves the internal pointer of an array. Meaning that it's arguments are a reference to the array variable. The problem is that he is calling end() on a return value from array_keys. Since this is a value that is returned, it can't be passed as a reference, because it is not really a variable. So as the second one I posted says, return the value of array_keys to a variable, then use end on the variable to move the internal pointer. <?php $array = array("apples" => "oranges", "monkeys" => "kittens"); $theKeys = array_keys($array); if (end($theKeys) == "monkeys") { echo "Monkeys are everywhere!"; } echo "End"; -
Try $query->execute(array("column" => $data)); without the bindParam
-
Yes, but you'll need to use similar radio names to make the select functionally work as they should <input type="radio" name="radiobutton[0]" value="a"><br> <input type="radio" name="radiobutton[0]" value="b"><br> <input type="radio" name="radiobutton[1]" value="a"><br> <input type="radio" name="radiobutton[1]" value="b"><br>
-
If you already have the data in a database, which it appears you do, since you are outputting those values to the page, then just assign the id to the checkbox and then on the next page, pull those values from the database for the checkboxes that are checked. So say you have multiple groups: <input type="checkbox" name="response[]" value="<?php echo $id;?>"> Option 1 <br /> // Next loop <input type="checkbox" name="response[]" value="<?php echo $id;?>"> Option 2 Then you can loop through the values in PHP. foreach ($_POST['response'] as $theID) { }
-
How Should I Properly Structure My Website?
teynon replied to BorysSokolov's topic in PHP Coding Help
Create a header and footer file and include them on every page. If you create one page that does everything, eventually, that page is going to become a big blob of programming code that you hate to work on. You need to organize your code into pages that fulfill a specific purpose. When you say option 2 makes the code disorganized, then that is quite probably because you are not organizing it well. How is it becoming disorganized? -
I'm not sure if this is on purpose or not as well, but in Chrome on the main page, the footer appears before content.
-
I would push the top two tabs left a little. The tab hangs over the edge of the main container's rounded edges. Or you could remove the border-radius on just the top right box. Your dropdown navigation boxes could use a border to distinguish them slightly from the rest of the content. I would disable the options "---------------" in your select boxes. <option disabled="disabled">--------------------------------</option>
-
Javascript Confirm will not stop delete on my php code
teynon replied to rguitar's topic in Javascript Help
It would be the same case in jQuery, but using a different method. (I prefer jQuery as well.) But it was easier to recommend adding return here for simplicity's sake. If you were going to do it with jQuery, it would be something like this: $('#object').on("click", function() { if (confirm("Are you an oompa loompa?")) { return true; } return false; }); Personally, I wouldn't use an anchor tag ("<a>") in this case. I would probably use a button. -
You need to find the code in smarty / PHP that handles the processing of the form after the results have been submitted. Not the HTML form itself. Then you can modify the PHP code to not use buttons but instead rely on something else.
-
I'll move on to answering your question in a moment, but I'd like to hit another point first. I would recommend against running a query for every single file. If you end up with 500 files, you'll be running 500 queries. I might suggest a different approach. You could either get the entire list of files first and put it into an array and query using something like "where image IN ()". Or depending on you database, you could get the entire list of files in the database and compare that as you run through the files. I would prefer the first option, but from what I remember with MySQLi, it's kind of a PITA to get it to work with arrays. I typically prefer PDO. The reason you are getting the "BoatDock2004.jpg" again and again is because those values are being set once. When the statement returns no results, there are no replacements. So the quick fix for you here is to set the values at the beginning of each loop. if ($handle = @opendir("../../images/year/$year/")) { $blacklist = array('.', '..', 'index.php', 'index.html'); while (false !== ($file = readdir($handle))) { if (!in_array($file, $blacklist)) { $id = ""; $photoid = ""; $image = ""; $title = ""; $caption = ""; $idcheck = "Not found in database."; $admin = "<a href=\"../add/photos.php?image=$file&year=$year&timeofday=$timeofday\">Add</a>"; $details = ""; if ($stmt = $mysqli->prepare("SELECT id, image, title, caption, secureid FROM photogallery WHERE image = ? AND year = ? AND timeofday = ?")) { $stmt->bind_param('sis', $file, $year, $timeofday); $stmt->execute(); $stmt->store_result(); $stmt->bind_result($id, $image, $title, $caption, $photoid); $stmt->fetch(); $stmt->close(); } if ((!empty($id)) && (!empty($photoid)) && (!empty($image))) { $idcheck = "<font color=\"green\">Found in Database</font>"; $admin = "<a href=\"../edit/photos.php?photoid=$photoid\">Edit</a>"; $details = "<b>$title</b> $caption"; } echo "$file $image $details $idcheck $admin<br>"; } } closedir($handle); } else { echo "This image directory was not found."; } Edits: - Fighting the code block formatting...
- 3 replies
-
- directory list
- mysql
-
(and 1 more)
Tagged with:
-
Couple of things: 1) This is a javascript question wrapped inside of PHP code. 2) Don't use the "a" tag unless you plan on using it like a link. Instead, use another element like span and style it with a CSS class. This will make it so you don't have to override default behavior of anchors. 3) alert('MyMessage'); will show a message. If you don't want to do that ugly message box, then you'll need to look into some jQuery dialog boxes. http://jqueryui.com/dialog/
-
Javascript Confirm will not stop delete on my php code
teynon replied to rguitar's topic in Javascript Help
Add a return in the onclick. <tr><td <?php echo $RowColor ?>><?php echo $row['ClientName'] ?></td><td <?php echo $RowColor ?>><?php echo $row['PatientName'] ?></td><td <?php echo $RowColor ?>><?php echo $row['IDNumber'] ?></td><td <?php echo $RowColor ?>> <?php echo $row['Age'] ?></td><td <?php echo $RowColor ?>><?php echo $row['Sex'] ?></td><td <?php echo $RowColor ?>><?php echo $row['Doctor'] ?></td><td <?php echo $RowColor ?>><?php echo $row['Results'] ?></td><td><a href="brucella.php?id=<?php echo $row['Id'] ?>" onclick="return warning();">Delete</a></td></tr> -
Usually the rainbow tables will take effect after they've already compromised your database. Yes, you should always prevent multiple failed login attempts. You will always have users who use the shortest password they can think of. Requiring the user to use other symbols and numbers forces them to increase the complexity of their password. They often still want the passwords because that will enable them to access the website and any other website the user might be using the same password on. I should probably clarify that I was pointing out the relevance to the rainbow tables in the original question. Perhaps we are arguing the same point, whereas I thought you were arguing against the user restrictions.
-
Only variables should be passed by reference
teynon replied to tobimichigan's topic in PHP Coding Help
hah, my bad. $keys = array_keys($id); if ($element_item_key !== end($keys)) -
While this is an entertaining comic, it's not necessarily accurate to real word scenarios. http://en.wikipedia.org/wiki/Password_strength The point here is that more complex passwords secure against common passwords being guessed. As far as I know, there is no way to 100% secure against rainbow tables (except securing your database so that no one can download it) and simple passwords are likely to open up your entire database as they will probably be found first. Once they find one, they can typically find them all. Consider a database containing passwords with no complexity restrictions. It would likely be filled with these types of passwords: (http://www.cbsnews.com/8301-205_162-57539366/the-25-most-common-passwords-of-2012/) If I had access to a database with no restrictions on the password, I would go off of that list first and try those. If there is a password in there like those ones, it would likely be a very quick decoding of the passwords.
-
Tell me which password would be harder to guess: smallpassword areallylongpasswordwithlotsofoptions Now, what really makes the passwords secure is a user picking a complex password. If I remember correctly (could be wrong), rainbow tables use a guess and check style approach. If all the passwords in the database are simple passwords like "mypassword", then the database will be vulnerable. Your best option is to make sure that your users have strong passwords. For example, requiring their password be at least 8 characters, consisting of numbers, letters, and special characters. How far you run with that approach is up to you.
-
Only variables should be passed by reference
teynon replied to tobimichigan's topic in PHP Coding Help
Assign end to a value. end returns a reference to a value in the array. Try $last = end(array_keys($id)); if ($element_item_key !== $last) -
"You're not very smart." Remove the word not, and it's a pretty nice statement as well.
-
<?php function DateCmp($a, $b) { if (strtotime($a) == strtotime($b)) { return 0; } return (strtotime($a) < strtotime($b)) ? -1 : 1; } ?> Make sure to wrap your code in code blocks ("<>" Button)
-
I'd say Jessica responded appropriately. The question was formed in a very heavy tone and very biased. Her comment was to the point. As for asking a question, I'd say this was formed more as a rant than a question.
-
This shows statistics of outward facing websites: http://w3techs.com/technologies/details/pl-php/all/all There are many inward facing (intranets) that still use PHP 4. My work FINALLY upgraded to 5.3. But they haven't pushed those changes out to customers yet.
-
You should explode this three times. First, you are getting the parameters. The second time, getting the values of what they are buying. The third, you are breaking down the details of the item. $string = "SMART WAL BUY 2-A,1-B,3-D"; $parameters = explode(" ", $string); if ($parameters[0] == "SMART") { if ($parameters[1] == "WAL") { if ($parameters[2] == "BUY") { $purchases = explode(",", $parameters[3]); foreach ($purchases as $purchase) { $itemInfo = explode("-", $purchase"); addToOrder($itemInfo[0], $itemInfo[1]); // Create function for saving order, addToOrder($qty, $item); } } } }