|
fuf posted:I'm looping through wordpress posts and want a new line after every three posts. Normally you would handle presentation issues like this in CSS, is there a functional reason for needing to place a linebreak on every third post or is it purely for looks? If it's purely for looks, use CSS instead.
|
# ? Oct 21, 2012 23:15 |
|
|
# ? May 19, 2024 16:27 |
|
Worked on my code some more and got it working. It was working fine, adding users like it should, but when I came back an hour later it suddenly didn't work anymore I've doublechecked and restarted everything, but I can't figure out what's going on. Whitespace doesn't matter, does it? edit: Found it, crypt() was loving things up. php:<?php $mysqli = new mysqli("localhost", "", "", ""); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $business_n = $mysqli->real_escape_string($_POST['business_n']); $contact_n = $mysqli->real_escape_string($_POST['contact_n']); $industry = $mysqli->real_escape_string($_POST['industry']); $email_address = $mysqli->real_escape_string($_POST['email_address']); $email_address2 = $mysqli->real_escape_string($_POST['email_address2']); $mailing_address = $mysqli->real_escape_string($_POST['mailing_address']); $city = $mysqli->real_escape_string($_POST['city']); $postcode = $mysqli->real_escape_string($_POST['postcode']); $phone_nr = $mysqli->real_escape_string($_POST['phone_nr']); $abn = $mysqli->real_escape_string($_POST['abn']); $password = $mysqli->real_escape_string($_POST['password']); $password2 = $mysqli->real_escape_string($_POST['password2']); $secret = $mysqli->real_escape_string($_POST['secret']); $answer = $mysqli->real_escape_string($_POST['answer']); $terms = $_POST['terms']; if(empty($email_address)) { echo "Email required."; } elseif (empty($email_address2)) { echo "Email required."; } elseif (empty($password)) { echo "Password required."; } elseif (empty($password2)) { echo "Password required."; } elseif (empty($secret)) { echo "Secret question required."; } elseif (empty($answer)) { echo "Secret answer required."; } elseif (empty($terms)) { echo "You have to agree to the terms and conditions."; } elseif (($email_address != $email_address2)) { echo "Email doesn't match."; } elseif (($password != $password2)) { echo "Passwords don't match."; } else { $mysqli->query("INSERT INTO members VALUES (NULL, '$business_n', '$contact_n', '$industry', '$email_address', '$mailing_address', '$city', '$postcode', '$phone_nr', '$abn', crypt('$password'), CURRENT_TIMESTAMP, '0', crypt('$secret'), crypt('$answer'))"); } $mysqli->kill($thread_id); $mysqli->close(); ?> Fleur Bleu fucked around with this message at 08:36 on Oct 22, 2012 |
# ? Oct 22, 2012 08:26 |
|
Fleur Bleu posted:
Why are you calling kill? I have never seen this and it seems like a bad idea. This is killing the thread, I assume that means that close never actually gets called on it since the process is already dead. If it worked that way you would end up with a hanging open connection every time the script runs. Also, you should consider generating your own salt for crypt as weird things could happen if you move your script to a different server. Crypt does different things depending on how the OS is configured.
|
# ? Oct 22, 2012 13:40 |
|
Why are you not using PDO and parameterised queries?
|
# ? Oct 22, 2012 13:48 |
|
Also would doing crypt() on a real_escape_string()'d string cause problems? If anything was escaped/required to be escaped your crypt would be on a string with extra slashes and poo poo and not the original. Or maybe not, I've never bothered checking.
The Gripper fucked around with this message at 14:00 on Oct 22, 2012 |
# ? Oct 22, 2012 13:51 |
|
The Gripper posted:Also would doing crypt() on a real_escape_string()'d string cause problems? If anything was escaped/required to be escaped your crypt would be on a string with extra slashes and poo poo and not the original. Or maybe not, I've never bothered checking. Yes, it would cause problems if special characters were used in the password. It should be ran through crypt then escaped. Otherwise you will always need to run a password through real_escape_string() first, before checking running crypt on it and checking the value against the db value.
|
# ? Oct 22, 2012 14:07 |
|
Gnack posted:Normally you would handle presentation issues like this in CSS, is there a functional reason for needing to place a linebreak on every third post or is it purely for looks? If it's purely for looks, use CSS instead. Yeah it's purely for looks, but I don't know how I would do it with just CSS. I need PHP to tell me whether a post should be on the start of a new row so I know when to close the last row and start a new one. I guess I could have written the CSS better so that each row didn't have its own container, but that's the way it's laid out...
|
# ? Oct 22, 2012 14:41 |
|
fuf posted:Yeah it's purely for looks, but I don't know how I would do it with just CSS. I need PHP to tell me whether a post should be on the start of a new row so I know when to close the last row and start a new one. I guess I could have written the CSS better so that each row didn't have its own container, but that's the way it's laid out... div:nth-child(Xn+Y) {} or something?
|
# ? Oct 22, 2012 14:44 |
|
Gnack posted:Normally you would handle presentation issues like this in CSS, is there a functional reason for needing to place a linebreak on every third post or is it purely for looks? If it's purely for looks, use CSS instead. This should be done in CSS. Also, you're making a lot of extra work for yourself. I don't use WP, so this is a 'logically works, but will be untested': code:
Viggen fucked around with this message at 20:48 on Oct 22, 2012 |
# ? Oct 22, 2012 20:31 |
|
Does anybody have any experience with HipHop? Are there any gotchas (besides the lack of eval) to look out for? Does it work pretty well for CLI PHP applications?
|
# ? Oct 22, 2012 21:51 |
|
oRenj9 posted:Does anybody have any experience with HipHop? Are there any gotchas (besides the lack of eval) to look out for? Does it work pretty well for CLI PHP applications? I think the first question anyone would ask is why are you using it?
|
# ? Oct 22, 2012 21:59 |
|
musclecoder posted:I think the first question anyone would ask is why are you using it? Haha, I had three paragraphs written about that, but decided to delete it. Suffice to say that distributing the software I'm currently working on as a pre-compiled binary would dramatically cut down on the amount of system administration work that I have to perform. My desire is to make it sufficiently difficult for anybody with access to the machine to modify our source code and have it redirect the data we collect somewhere else.
|
# ? Oct 22, 2012 22:26 |
|
oRenj9 posted:My desire is to make it sufficiently difficult for anybody with access to the machine to modify our source code and have it redirect the data we collect somewhere else. How often do you push code? You're going to lose all of the benefits of PHP and end up with a slower runtime and people without the ability to decode a lot of the issues which occur.. Facebook uses this. Look at how stable Facebook is.
|
# ? Oct 22, 2012 22:55 |
|
oRenj9 posted:Haha, I had three paragraphs written about that, but decided to delete it. Suffice to say that distributing the software I'm currently working on as a pre-compiled binary would dramatically cut down on the amount of system administration work that I have to perform. My desire is to make it sufficiently difficult for anybody with access to the machine to modify our source code and have it redirect the data we collect somewhere else. Got it. That makes more sense, just ensuring you weren't going to say because you had scalability issues in line with Facebook's. That said, I only played around with it when it was first released. It was easy enough to get set up (aside from originally reporting a bug https://github.com/facebook/hiphop-php/issues/2 it was easy after that). But that was 3 years ago, compiling it should be pretty simple now. And I remember they got it working with Wordpress, so if they can do that, I imagine that your CLI app would be easier to get set up with it.
|
# ? Oct 22, 2012 23:03 |
|
oRenj9 posted:My desire is to make it sufficiently difficult for anybody with access to the machine to modify our source code and have it redirect the data we collect somewhere else. Well, you can ease source code distribution by using PHARs, but source and data protection is going to be difficult to pull off. If you don't control the server, there is nothing -- nothing -- that you can do that a dedicated pirate can't undo. Your best protection against intellectual property theft isn't technological, it's legal. Don't forget that the binaries that HipHop produces are huge. It's almost certainly not the solution you're looking for here.
|
# ? Oct 22, 2012 23:16 |
|
Begby posted:Why are you calling kill? I was browsing the mysqli function list, wondered what kill did, skimmed it's article, saw "kill process" and I thought "Thats sounds good, let's put that in.". Looking at it again, the examples use it the same way I do. But your explanation makes sense, so I'll just scrap it. Biowarfare posted:Why are you not using PDO and parameterised queries? I'm just looking things up as I go along, so I started with mysqli. If I have enough time I'll try and do everything in PDO instead. The manual has a lot of options, which is good, but I lack the knowledge to make the right choices.
|
# ? Oct 23, 2012 02:54 |
|
Fleur Bleu posted:I'm just looking things up as I go along, so I started with mysqli. If I have enough time I'll try and do everything in PDO instead. The manual has a lot of options, which is good, but I lack the knowledge to make the right choices. Mysqli also supports parameterized queries (although I prefer PDO's syntax). You're better off using those instead of escaping all the input and building the raw statement in code.
|
# ? Oct 23, 2012 21:22 |
|
There's one thing about mysqli_stmt_bind_param() that can just gently caress right off: the first paramater being $types. Other than for blobs, what's the goddamn use? A statement like: PHP code:
I am angry because every time I use this goddamn thing I forget the typestring because literally no other implementation in any language requires it, and requiring it here and not even using it is literally hitler. MySQL doesn't care e.g. code:
The Gripper fucked around with this message at 22:08 on Oct 23, 2012 |
# ? Oct 23, 2012 22:02 |
|
Use PDO.
|
# ? Oct 23, 2012 22:12 |
|
I'm a MacGyver-esque coder that swoops in to patchwork fix broken things so my only contact with mysqli is in situations where it'd be rude to just replace it, from a maintenance standpoint at least. If I ever have a situation where I'm going to be jiggering an entire system and not just a small part then I'll be using PDO.
|
# ? Oct 23, 2012 22:53 |
|
The Gripper posted:There's one thing about mysqli_stmt_bind_param() that can just gently caress right off: the first paramater being $types. YES. I've used a wrapper around Mysqli that treats every parameter like a string, and I don't think there's even one example of the conversion causing different results. It's a completely worthless interface wart.
|
# ? Oct 24, 2012 02:01 |
|
Fleur Bleu posted:I was browsing the mysqli function list, wondered what kill did, skimmed it's article, saw "kill process" and I thought "Thats sounds good, let's put that in.". Looking at it again, the examples use it the same way I do. The big problem I can imagine is if you're doing something big that the script isn't blocking over (e.g., running "UPDATE bigasstable SET x = y") you can kill the thread halfway into doing something. I only kill threads when something's gone completely off the rails and is locking tables and causing huge traffic jams. My boss did the same thing with mysql_free_result() and just started copy-pasting it after every mysql_query() (even ones that mysql_free_result() makes no sense for, like INSERT or UPDATE). Please don't be my boss.
|
# ? Oct 24, 2012 02:32 |
|
The Gripper posted:You can probably just stick with the original gpg, it's still being maintained. PS, thanks for this, I've got it working when run manually, need to do some security stuff to get it working through the Apache/PHP user but it works in concept at least. Thanks!
|
# ? Oct 24, 2012 20:01 |
|
So I'm having trouble fixing up a function I wrote for a homework assignment. Here's what I have so far: E: Solved The goal of the function is to handle a folder. If it's a folder it should call itself, but if its a .htm or .html file it should call the "Process file" function. My problem is that when it gets to a folder inside a folder, it prints "Inside the while loop with said folder" but then just stops and doesn't step through that folder. Thanks in advance. I made it an image so I could take it down when I'm done. Good Will Hrunting fucked around with this message at 20:17 on Oct 25, 2012 |
# ? Oct 25, 2012 17:52 |
|
Good Will Hrunting posted:So I'm having trouble fixing up a function I wrote for a homework assignment. Here's what I have so far: PM me the code and I'll take a look, I've got some time to kill.
|
# ? Oct 25, 2012 19:27 |
|
Good Will Hrunting posted:So I'm having trouble fixing up a function I wrote for a homework assignment. Here's what I have so far: The problem is that is_dir() and is_file() need the full path to the directory/file you want to test whereas readdir() only returns the name of the directory/file. Therefore line 6 of the function should probably be: code:
code:
Pile Of Garbage fucked around with this message at 20:24 on Oct 25, 2012 |
# ? Oct 25, 2012 19:32 |
|
You guys are the best. Seriously, thanks so much for the help.
|
# ? Oct 25, 2012 20:15 |
|
Good Will Hrunting posted:You guys are the best. Seriously, thanks so much for the help. My pleasure. Now pair that code with something like this and could be pretty slick looking! http://jquery.bassistance.de/treeview/demo/
|
# ? Oct 25, 2012 20:37 |
|
I ran out of entropy today root@530w6th-fs2app1:~# cat /proc/sys/kernel/random/entropy_avail 0 Should I regenerate any hashes or bcrypted things that were created or are they cryptographically sound (webapp, invalidate passwords for new registraitons during that period and make them reenter a new one on next login)?
|
# ? Oct 25, 2012 22:08 |
|
That counter is only valid if you're reading out of /dev/random itself. Reads from /dev/random will block until there is enough entropy available. There's no need to worry or change anything, because none of the things you have mentioned are likely to have either used /dev/random directly. Keep in mind that /dev/urandom is a different thing than /dev/random.
|
# ? Oct 25, 2012 22:16 |
|
fuf posted:Yeah it's purely for looks, but I don't know how I would do it with just CSS. I need PHP to tell me whether a post should be on the start of a new row so I know when to close the last row and start a new one. I guess I could have written the CSS better so that each row didn't have its own container, but that's the way it's laid out... Biowarfare posted:div:nth-child(Xn+Y) {} or something? Yep, you'd say: code:
|
# ? Oct 26, 2012 00:57 |
|
code:
This is line 53: <?php require("scalesheader.php"); ?> We were on Windows hosting and they switched us to linux hosting and it broke everything. I need help bad as its basically messed up our entire website.
|
# ? Oct 26, 2012 15:58 |
|
Is that file readable by the program running the webserver?
Golbez fucked around with this message at 16:26 on Oct 26, 2012 |
# ? Oct 26, 2012 16:23 |
|
Golbez posted:Is that file readable by the program running the webserver? To be honest I am not quite sure. I compared it to other files that are being read on the webpage and those are working and these are not.
|
# ? Oct 26, 2012 16:30 |
|
Flaggy posted:
Are you using any type of auto loader that depends on backward slashes instead of forward slashes? Something for Windows only that doesn't use PATH_SEPARATOR? Also, fire your web host. How can they just change operating systems on you!? That's insane.
|
# ? Oct 26, 2012 17:02 |
|
musclecoder posted:Are you using any type of auto loader that depends on backward slashes instead of forward slashes? Something for Windows only that doesn't use PATH_SEPARATOR? The webhost was godaddy. Wooo. Unfortunately we are locked in with them. The coder we had for the site quit a while back and I was thrust into this role, to be quite honest, I don't know that much about php. I don't know if its using an autoloader or not. They switched us from Windows hosting to Linux hosting because they said Windows couldn't support the PHP. Our entire site is php. I appreciate any help.
|
# ? Oct 26, 2012 17:07 |
|
Check the case of all the filenames and directories. Windows is not case sensitive, but Linux is.
|
# ? Oct 26, 2012 17:19 |
|
DaWolfey posted:Check the case of all the filenames and directories. Windows is not case sensitive, but Linux is. Thats exactly what it is, thank you so much, need a forums upgrade or anything? I think I owe a bunch of those in this thread. Thanks again.
|
# ? Oct 26, 2012 18:34 |
|
I am looking at learning PHP so I can use Zend Studio to make native apps. My question is are there any code academy type sites worth looking at? Where there is a built in console to test your tutorial code? I presume I just need to learn PHP and not Zend specific tutorials?
|
# ? Oct 26, 2012 21:19 |
|
|
# ? May 19, 2024 16:27 |
|
thegasman2000 posted:I am looking at learning PHP so I can use Zend Studio to make native apps. My question is are there any code academy type sites worth looking at? Where there is a built in console to test your tutorial code? I presume I just need to learn PHP and not Zend specific tutorials? I don't know about interactive tutorials for learning PHP, although there are some sandboxed PHP interpreters on the internet that you can use to test your code. You can also download and install PHP, and test your work out by running your scripts locally. The main thing you have to know about PHP is that there are a lot of really bad and outdated tutorials out there giving bad advice. Before you settle on a learning resource, try to find out when it was written, how actively it has been updated since then, and for which version of PHP it was written. The current major version of PHP is 5; don't use a resource that was written for PHP 4. One good way to identify fairly quickly whether a resource is giving bad advice is to look at its coverage of database interaction. If it tells the reader about how to access a database using the mysql_* family of functions, it's most likely a bad resource. Edit: By the way, I just thought to check the OP of this thread, and it contains a link to W3Schools' PHP coverage, which is not exactly great. Does anybody know whether Duz still posts? Hammerite fucked around with this message at 02:58 on Oct 27, 2012 |
# ? Oct 27, 2012 02:54 |