|
MrMoo posted:Which bit is the problem? I hope you have saved the items checked out with some unique id somewhere. Then to check-in you pull that list of items, iterate over them generating the HTML as necessary for your check boxes, etc. That's exactly what I needed to know! Thanks! I'm new to PHP and what it can do with HTML. I didn't know that it could be used in such a fashion or what the proper syntax was to implement it. This is perfect. It's going to make generating other things for my program so much easier.
|
# ? Jan 22, 2010 09:23 |
|
|
# ? May 15, 2024 17:16 |
|
fletcher posted:Ummm really? The DOMDocument solution is so much cleaner... Your version is much cleaner: as I said mine was ugly and brutish - but it worked. Since I'm not familiar with DOMDocument, I stuck to what I could whip up an answer in 15 minutes with. The difference being I would have had to lookup DOMDocument, whereas I can just write out simple regex like that. Having seen your version; I will make a note to GET familiar with DOMDocument... How well does it deal with malformed (x)html? Or fragments? Whats its memory footprint like?
|
# ? Jan 22, 2010 12:32 |
|
armed2010 posted:That's exactly what I needed to know! Thanks! As a side item, you can do this as an alternate syntax to what MrMoo suggested php:<?php foreach ($items as &$item): ?> <input type="checkbox" name="<?= $item->name; ?>"> <?php endforeach; ?> This also works with if, for, and while. I have been coding php for like 10 years, and I actually only found that out last year. I R Awesome. Bonus syntax options (just so you can see the flexibiility in what you have to work with) php:<?php foreach ($items as &$item) { echo '<input type="checkbox" name="'.$item->name.'">'; } ?> php:<?php foreach ($items as &$item) { echo "<input type=\"checkbox\" name=\"{$item->name}\">"; } ?>
|
# ? Jan 22, 2010 18:39 |
KuruMonkey posted:How well does it deal with malformed (x)html? Or fragments? Whats its memory footprint like? It does what it can with malformed html but it will fail if it's really malformed. It can do fragments as well, you don't need an entire page. No idea about the memory footprint, at that point you should probably be using a real API.
|
|
# ? Jan 22, 2010 20:18 |
|
Begby left out one more option, using heredoc:php:<? foreach ($items as &$item) { echo<<<MOO <input type="checkbox" name="{$item->name}"> MOO; } ?>
|
# ? Jan 23, 2010 02:19 |
|
This will never end. The scraping code I set up earlier seemed to work great, but I noticed it skipped a about a third total of the listings. I looked through the records and matched them against the pages, and apparently when the page just gets too darn long (example: http://www.songmeanings.net/artist/directory/m/) it stops and jumps to the next one or something. Anyone have an idea why? I can't see any particular reason it would do that, and it's not giving me an error code or anything.
|
# ? Jan 26, 2010 04:14 |
|
apekillape posted:This will never end. Curl is timing out. Set the curl timeout to a higher value.
|
# ? Jan 26, 2010 05:00 |
|
DarkLotus posted:Curl is timing out. Set the curl timeout to a higher value. It wasn't set at all before, I added the line and set it to 30, then 60. It still stops after 519 records. I haven't gone to song source page and counted all of them directly, but as it has nothing from the Mu- section (that's how I originally noticed) I assume it's just getting stopped somewhere way before it's over for that section, and skipping ahead.
|
# ? Jan 26, 2010 05:42 |
|
apekillape posted:It wasn't set at all before, I added the line and set it to 30, then 60. It still stops after 519 records. I won't pretend to be an expert. Look into CURLOPT_BUFFERSIZE and CURLOPT_CONNECTTIMEOUT.
|
# ? Jan 26, 2010 05:48 |
|
I made a little room booking database to use in the school I work at. On the odd occasion a teacher will press submit twice when booking a room (I assume that's what's happening) and it'll enter the database twice. I wrote a couple of lines to check for duplicate data but it doesn't seem to work. Here's the code to check for duplicates: code:
code:
code:
|
# ? Jan 26, 2010 17:09 |
|
ryo posted:Any ideas? In your if statement are you doing any kind of exit? Is the insert in an else clause as part of that if? I think what is happening is that the insert is happening no matter what since you aren't skipping it if the result is true. On a side not, holy loving poo poo this code is really insecure. You need to use prepared statements or at the very least do some sort of cleaning/checking of the data you are including in your queries. Take a look at PDO. Edit: Oh yeah, does your link ever show up? Have you tried running your select query in an sql editor to make sure it works properly with some test data (or echo your query, copy it, then paste it write into your sql query program). Begby fucked around with this message at 17:22 on Jan 26, 2010 |
# ? Jan 26, 2010 17:18 |
ryo posted:Any ideas? Since it's for a smaller app, just disable the submit button after they click it so they can't click it twice. Also, use PDO as already has been suggsted. Again, since it's a small app, people probably won't be trying to do SQL injection, but that code you posted is frightening.
|
|
# ? Jan 26, 2010 20:25 |
|
Either disable the submit button on form submission (the simple way), or add in a unique indexed column to your database to prevent duplicate data from being posted (the other simple way.) On your form, have PHP generate a hidden input field with uniqid() as the value, and use that data as your unique key. Then, if someone double-submits, the data should only be added once (the query on the second insert would fail because of the unique key data submitted.) You can also probably work it into your app as a CSRF token if it's a publicly available script, which would also help secure it up a bit.
|
# ? Jan 27, 2010 01:57 |
|
I made it a few years ago when I was an innocent butterfly with no considerations for SQL injections etc. Luckily the MySQL user for this doesn't have privaleges for any other DB. Thanks for the suggestions!
|
# ? Jan 27, 2010 12:02 |
|
I have a remote MySQL 5.1 server that I am trying to connect to via SSL. From the command line on the web server (FreeBSD 8, Apache 2.2, PHP 5.2.x), I can use the mysql client and connect just fine by specifying the location of ca-cert.pem, but when I try to connect using mysqli the page just hangs. 'Show processlist' on the remote databases's side shows pre:+----+----------------------+--------------------+------+---------+------+-------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+----------------------+--------------------+------+---------+------+-------+------------------+ | 2 | unauthenticated user | <web ip>:58711 | NULL | Connect | NULL | login | NULL | +----+----------------------+--------------------+------+---------+------+-------+------------------+ php:<?php $conn = mysqli_init(); $conn->ssl_set(NULL, NULL,"/var/www/certs/ca-cert.pem", NULL, NULL); $conn->real_connect($ip, $user, $pwd, $db, 3306, NULL, MYSQLI_CLIENT_SSL); ?> SmirkingJack fucked around with this message at 16:01 on Jan 27, 2010 |
# ? Jan 27, 2010 15:53 |
|
How do I chmod folders that have been uploaded to the server via FTP ? I work in Windows and have a framework with lots of sub folders. When I upload a website to the internet, I have a "setup" script that I first run that sets lots of things up, and sets a bunch of folders that need to be written to (via administration, or log files) to 755 or I even tried 777 but it fails. I can make a directory and write files in a folder, but I can't CHMOD an existing folder (I'm guesssing it's owner is my FTP login). How do I get around this ? I used to connect via FTP and ftp_chmod the folders but I'm trying to do this without FTP. I can't be the only one who transfers his website via FTP and then wants to be able to CHMOD ?
|
# ? Jan 27, 2010 17:18 |
|
Yossarko posted:How do I chmod folders that have been uploaded to the server via FTP ? One option is to use PHP's FTP extension. Another is to make one writable folder that holds all the others, since the new folders you create there should inherit permissions by default.
|
# ? Jan 28, 2010 01:08 |
|
I'm looking at upgrading an online store I run, and I was wondering what PHP based stores people would recommend? (Not sure if this thread is the right place for this, I hope so.) I'm kind of torn between using an out of the box solution or biting the bullet and programming my own as obviously most online solutions are bloated to hell. Whenever I decide to tackle it myself, I think of all the different aspects of an online store and get scared off by the scale. I'm not sure I want something as large scale as Magento. I currently use Trading Eye which is fine, but the urls are a bit nasty and the search functionality is a bit poo poo. I'd like something that is well programmed, simple to theme and of course secure. I also need to consider google sitemaps and such too.
|
# ? Jan 29, 2010 10:36 |
|
Hanpan posted:I'm looking at upgrading an online store I run, and I was wondering what PHP based stores people would recommend? (Not sure if this thread is the right place for this, I hope so.) Personally, Because it's what i know - I'd use Drupal with the UberCart module.. there's alot of support for it, but it can be a bit tricky getting used to hacking it to do what you want, if it's a little more specific. Most of the time there's a module for what you need, and someone else has usually done it before..
|
# ? Jan 29, 2010 15:42 |
|
I'm in the process of finishing up a website for an estate agent, and a small issue has cropped up during testing. My client has the ability to upload floorplans to their website, which get resized automatically by the code I've written. However, a lot of these files come with a large amount of whitespace around the edge. I'm using GD2 to do the resizing, and I can't find any obvious way to detect large areas of whitespace and crop it outside of imagecolorat(), a loop, and probably too much processing time. Is this going to be a plausible solution? Is there a better way of doing it? Should I just advise they crop off large areas of whitespace in Photoshop before uploading (they'd be comfortable doing this)?
|
# ? Feb 1, 2010 13:56 |
|
Finite posted:Is this going to be a plausible solution? Is there a better way of doing it? Should I just advise they crop off large areas of whitespace in Photoshop before uploading (they'd be comfortable doing this)? Uh yeah.
|
# ? Feb 1, 2010 14:32 |
|
apekillape posted:It wasn't set at all before, I added the line and set it to 30, then 60. It still stops after 519 records. How many characters?
|
# ? Feb 1, 2010 19:04 |
|
ryo posted:
Apart from a redundant 'jebus, escape those POST values', I think you're probably testing for the string literal rather than the variable. eg '$_POST[bookdate]' rather than '1264507200'. You should also string the elements ($_POST['bookdate']) and avoid string interpolation because it makes the baby jesus cry. Mysql_real_escape_string may just save your life.
|
# ? Feb 1, 2010 19:11 |
|
Finite posted:I'm in the process of finishing up a website for an estate agent, and a small issue has cropped up during testing. This isn't GD2, but if you have access to ImageMagick, perhaps this script could be useful: autotrim I have no idea how much processing time it requires, however.
|
# ? Feb 2, 2010 02:07 |
|
Hav posted:How many characters? I'm sorry, what do you mean?
|
# ? Feb 2, 2010 10:22 |
|
This might be the easiest question in here, as I know nothing about PHP. I just installed ZenPhoto on my site and I'm having some issues with the code. My problem right now is that the page with all the images on it displays the actual text "view slideshow" as the link to the slideshow page. I would really prefer it to be a button instead, but have no idea how to make it insert an image in that spot. I'm pretty sure this is the line that does it: code:
|
# ? Feb 3, 2010 01:38 |
|
electricHyena posted:This might be the easiest question in here, as I know nothing about PHP. I just installed ZenPhoto on my site and I'm having some issues with the code. There will be a function called "printSlideShowLink()" somewhere in ZenPhoto. It looks like it takes a string argument, which is being obtained form some sort of localization function 'gettext()' I'm guessing this function spits out a string like: code:
code:
|
# ? Feb 3, 2010 04:18 |
|
Lumpy posted:being obtained form some sort of localization function 'gettext()' Just a little aside: http://php.net/manual/en/book.gettext.php Its PHP's built in localisation.
|
# ? Feb 3, 2010 15:24 |
|
KuruMonkey posted:Just a little aside: Ahh, cool. I use my framework's localization stuff, had no clue PHP even had that built in. One of these days I should actually just spend some time reading the manual. I picked up PHP as a "solve this specific problem" tool, so I know the parts of it I've used well, but never really looked around at the rest of it much. Then again, I don't do all that much PHP any more.
|
# ? Feb 3, 2010 17:28 |
|
apekillape posted:I'm sorry, what do you mean? How many characters is the 519 records that you're returned before the thing stops? 519 seems a little arbitrary.
|
# ? Feb 3, 2010 21:11 |
|
Thanks Lumpy, it worked great!
|
# ? Feb 4, 2010 02:30 |
|
Sebbe posted:This isn't GD2, but if you have access to ImageMagick, perhaps this script could be useful: autotrim This was a bit too vicious for what I had in mind, so after some tests I wrote my own to see if I could make it better. Ended up as far too intensive for what I had in mind, so pre-cropping the images turns out to be the more sensible solution aside from writing a little client-side uploader to help them out. Too much work for a small problem, so I've abandoned the idea. Thanks for the link though.
|
# ? Feb 4, 2010 10:46 |
|
Anyone have anything interesting to say about Facebook's HipHop PHP compiler? meh. Pretty significant accomplishment to get something like this into large-scale production, but it's not really a bold new idea.
|
# ? Feb 4, 2010 23:48 |
|
supster posted:Anyone have anything interesting to say about Facebook's HipHop PHP compiler? Every big PHP application I've ever dealt with spends the great majority of its actual running time waiting for databases rather than actually executing PHP. I can't imagine using it unless I had an app running on a thousand servers.
|
# ? Feb 4, 2010 23:53 |
|
Yes, but at the scale HipHop is intended to be used at you've already moved so much of your data to memory (via memcached) that PHP execution starts becoming the bottleneck - which is where stuff like HipHop comes in. I certainly wasn't implying anyone in this thread should consider using it - there's only a small handful of PHP sites out there that are at the level where something like this would have any significant impact. supster fucked around with this message at 00:22 on Feb 5, 2010 |
# ? Feb 5, 2010 00:20 |
I've got some php code that produces a table, and it leaves a large quantity of whitespace at the top of the page, such that I have to scroll down to see the table. The code is as follows: code:
Anybody know what's going wrong?
|
|
# ? Feb 5, 2010 03:55 |
a foolish pianist posted:I've got some php code that produces a table, and it leaves a large quantity of whitespace at the top of the page, such that I have to scroll down to see the table. Looks like your <table> isn't structured quite right. Have a look at http://www.w3schools.com/tags/tag_table.asp Because your table is not structure properly, that <br> gets printed out BEFORE the table, causing that whitespace. Install firebug and you can see how Firefox interprets your malformed HTML. If you are just trying to get each row to be on a new line with that <br>, don't bother, each row will automatically be on new line. fletcher fucked around with this message at 04:02 on Feb 5, 2010 |
|
# ? Feb 5, 2010 03:59 |
Thanks. I'm feeling really stupid right now.
a foolish pianist fucked around with this message at 04:07 on Feb 5, 2010 |
|
# ? Feb 5, 2010 04:01 |
|
a foolish pianist posted:I've got some php code that produces a table, and it leaves a large quantity of whitespace at the top of the page, such that I have to scroll down to see the table. That's a plain old HTML question. ed darn,b
|
# ? Feb 5, 2010 04:02 |
|
|
# ? May 15, 2024 17:16 |
|
I found something that really confuses me about an application. There's a function that serializes an array and then posts that string to another file using cURL. That file just unserializes and the post and passes the data into a function. It looks to me like it would make far more sense just to pass the stuff straight into the function from the initial function. Is there any reason to do something like that?
|
# ? Feb 5, 2010 22:14 |