|
VerySolidSnake posted:This is a really bad idea. You have to write everything from scratch, opening up the potential of security holes and exploits. Frameworks have teams of people testing these things all the time, something Uncle Joe's PHP Framework will lack. Also, you are going to have to think of every possible way you might want to expand this thing, as you can accidentally put your entire site in handcuffs with a bad design decision early on. I did this "roll your own" thing on 3 websites, and I regretted it after spending the time to learn Yii. /index.php?id=5 $SQL = "SELECT * FROM TABLE WHERE id= ".$id; PHP isn't quite the cosmic horror it once was, but that doesn't change the fact that this dude was responsible for the terrible hell early php represented. duck monster fucked around with this message at 15:02 on Dec 24, 2011 |
# ? Dec 24, 2011 15:00 |
|
|
# ? May 15, 2024 17:45 |
|
DarkLotus posted:Let's say I have more than 2 arrays of supposedly unique values. How would I go about finding out if any one value in an array exists in the rest of the arrays? I am looking for a fairly fast way to do this without having to loop through each array manually and see if the value exists in any of the other arrays. To clarify, I'm hoping to avoid using in_array(), I'm also only interested in the whether "user" is duplicated. I'm not sure what the most computationally-efficient way of doing this is. Maybe something like the following would be worth trying. code:
|
# ? Dec 24, 2011 15:21 |
|
Hammerite posted:I'm not sure what the most computationally-efficient way of doing this is. Maybe something like the following would be worth trying.
|
# ? Dec 24, 2011 16:05 |
|
McGlockenshire posted:Anything cryptography-related can be dramatically slower in Windows due to how OpenSSL (doesn't) use Windows' built in crypto facilities. How is this a logical statement unless you have hardware crypto acceleration that isn't available via direct assembler?
|
# ? Dec 25, 2011 18:40 |
|
Wow, that was a while ago. I was referring to the fact that on Windows, the PHP OpenSSL extension's randomness generator is the worst, slowest possible choice. Various bugs were filed a few years ago. I believe they corrected the stupid calls in one of the 5.3.x releases.
|
# ? Dec 25, 2011 22:57 |
|
So I'm working on a database project which involves multiple calls to a database to fetch (reasonably small) amounts of data at a time. Since a lot of these calls can become repetitive, is it not faster to load the data into arrays in PHP and then query those arrays before reverting back to the database for additional information? In addition, what is the best way to time the speed of execution for PHP? It'd be useful to see for myself where I might be able to make things tick a little faster.
|
# ? Dec 26, 2011 11:25 |
|
Masked Pumpkin posted:So I'm working on a database project which involves multiple calls to a database to fetch (reasonably small) amounts of data at a time. Since a lot of these calls can become repetitive, is it not faster to load the data into arrays in PHP and then query those arrays before reverting back to the database for additional information? In addition, what is the best way to time the speed of execution for PHP? It'd be useful to see for myself where I might be able to make things tick a little faster. What exactly is this fetching? Why not nosql, memcached, or any of those?
|
# ? Dec 26, 2011 19:28 |
|
I'm just learning PHP, and I'm having the most difficult problem with two scripts working together. What I'm building is two forms that gather data. It's designed to be put up on a laptop or iPad at an event/con that we have so guests can fill out their user information. What I currently have is the first form that we fill out, saying who we are and where we are for our records. Then, once that information is submitted, it passes it on to the second form that gathers name, address, etc. The second script then combines information from the first form and second form and puts them together and inserts them into a MySQL database. Once the first form is done, it should redirect to the second form, which, upon submit, should reset and be ready for the next data entry. I have the second form working perfectly, and it inserts data wonderfully. The problem I am having is getting the second script to read from the first script. For clarity, I have a total of four files, two XHTML form files that post to the two PHP scripts that won't communicate. I have tried using cookies, which didn't work at all. I tried importing the first script in the second script which also didn't work. I thought about using GET, but the problem with get statements is that it would pass from the first script to the second script and skip over the second XHTML form. I'm kind of stuck here.. what should I try next?
|
# ? Dec 27, 2011 04:59 |
|
Captain Briney posted:I'm just learning PHP, and I'm having the most difficult problem with two scripts working together. Maybe your first form can insert data into the database and you can then call the second form with a variable like ?eventid=123 which will link the submission of the second form to the event or whatever.
|
# ? Dec 27, 2011 05:36 |
|
edit: Nevermind! Superglobals! Duh! Captain Briney fucked around with this message at 06:18 on Dec 27, 2011 |
# ? Dec 27, 2011 06:12 |
|
You probably shouldn't be using globals...
|
# ? Dec 27, 2011 09:20 |
|
Captain Briney posted:edit: Don't do this. Honestly, for something like this where you don't have much PHP experience, and it's going to be running on a laptop at a show, I'd set up a google form (http://www.google.com/google-d-s/forms/). After the show, export the spreadsheet from google docs to a csv, and dump it into the SQL database. Another option is to create a session table in your DB, serialize the data into a row in the DB, and pass back the session ID. Have them submit the additional data, combine it with what you've stored in the session DB, and only then commit the data as one transaction. Then, send a response to the client showing success, and destroy the session. I'd also destroy any existing sessions from the client machine when they first load the form. That way, you're not risking a client being able to get at someone else's personal info or incomplete data, especially if this is going to be on a publicly accessible site. DarkLotus's suggestion would work as well, but you'd need to make sure you couldn't put in an arbitrary eventid to get anyone's data. Plus, if the customer walks away or stops entering data, you'll have an incomplete record- better to commit all at once at the end.
|
# ? Dec 27, 2011 14:43 |
|
Null Set posted:Another option is to create a session table in your DB, serialize the data into a row in the DB, and pass back the session ID. There is zero advantage to doing this compared to just storing the data in the session on disk.
|
# ? Dec 27, 2011 16:25 |
|
Null Set posted:Don't do this. Thanks for this. I realized last night that using superglobals was a really stupid idea because of that exact reason. I'm still somewhat stuck, but I will try this serializing idea.
|
# ? Dec 27, 2011 22:38 |
|
Masked Pumpkin posted:So I'm working on a database project which involves multiple calls to a database to fetch (reasonably small) amounts of data at a time. Since a lot of these calls can become repetitive, is it not faster to load the data into arrays in PHP and then query those arrays before reverting back to the database for additional information? In addition, what is the best way to time the speed of execution for PHP? It'd be useful to see for myself where I might be able to make things tick a little faster. What database are you using? If you're working with a single script that queries/operates on some database data within the scope of a single request, then you should absolutely use arrays/objects (however you're storing the queried data), rather than re-querying the database at different points in the script. If you're using MySQL, the Query Cache is pretty simple to configure, and if your application is performing similar SELECT queries during every request it can speed things up a good deal. As far as measuring execution time, look at the examples and comments here. Googling turned up this, which looks alright. Orbis Tertius fucked around with this message at 02:02 on Dec 28, 2011 |
# ? Dec 28, 2011 01:47 |
|
McGlockenshire posted:There is zero advantage to doing this compared to just storing the data in the session on disk. I'd say there is- it becomes much easier to control who can retrieve what session data. Much easier to (for example) query for a session ID and IP/user id bound to it, than to try looking for a flat file with all that encoded into the filename. And if you're passing the filename back and forth, or parameters to fetch it- modify those parameters and whoops I have your session. I don't see the point in creating a bunch of flat files for data storage; what exactly makes you say there is no advantage in making use of the DB? Or is there another secure way of doing this that I'm overlooking?
|
# ? Dec 28, 2011 17:50 |
|
DarkLotus posted:I'm essentially wanting to print a list of the user accounts that are duplicated and reference which arrays they exist in along with all of the corresponding details tied to that user. Hammerite's solution is right, the real question for you is going to be how much work do you want to put into making it algorithmically efficient. If the list count is low then I wouldn't bother, but otherwise you're entering the exciting new world of sort and search algorithms!!! http://www.sorting-algorithms.com/
|
# ? Dec 29, 2011 01:21 |
|
Scaramouche posted:Hammerite's solution is right, the real question for you is going to be how much work do you want to put into making it algorithmically efficient. If the list count is low then I wouldn't bother, but otherwise you're entering the exciting new world of sort and search algorithms!!! Yeah, I knew it wouldn't be easy...
|
# ? Dec 29, 2011 01:39 |
|
Null Set posted:I'd say there is- it becomes much easier to control who can retrieve what session data. Much easier to (for example) query for a session ID and IP/user id bound to it, than to try looking for a flat file with all that encoded into the filename. No, I mean, store temporary data IN the session. That is what it is there for.
|
# ? Dec 29, 2011 08:50 |
|
I'm having trouble with a prepared parameterized query in PHP and at this point I don't know what I'm doing wrong. It doesn't appear to be an SQL issue (I already posted in the SQL thread assuming my SQL itself was wrong somehow) so it's either PHP or our Database class in PHP. We use ODBTP (http://odbtp.sourceforge.net/phpext-index.html) to connect to our SQL database, and our database class wraps the ODBTP functions to make them slightly easier to call (Hence prepare instead of odbtp_prepare) code:
[ODBTP][1]Parameter must be described (one for each $db->input) [ODBTP][1]Unbound parameter (one for each $db->set) [07002][0][Microsoft][ODBC SQL Server Driver]COUNT field incorrect or syntax error (when $db->execute is called) Originally I thought maybe I just couldn't use parameters as part of a join statement, but moving "AND titleno = ?" to after the "WHERE id= ?" doesn't work either. Maybe SQL prepared/parameterized queries just don't like joins as part of an update at all? It works fine if I build the queries by hand rather than using parameters. I'm completely baffled here.
|
# ? Dec 30, 2011 22:41 |
|
I know next to nothing about php, but I'm currently trying to set up a board using phpbb premod and the phpbb_seo mod. I've done .htmaccess and everything. I'm hoping there's someone here who might have used this.
|
# ? Dec 31, 2011 10:02 |
|
Captain Greed posted:I know next to nothing about php, but I'm currently trying to set up a board using phpbb premod and the phpbb_seo mod. I've done .htmaccess and everything. I'm hoping there's someone here who might have used this. I've installed PHPBB before (some time ago) but I do not recall running into any real difficulties. It pretty much does it all for you and tells you what you need to do at each stage. What in particular do you need help with?
|
# ? Dec 31, 2011 20:33 |
|
I've set up phpbb itself before--it's the phpbb_seo mod that's screwing me up. It rewrites URLs for SEO friendliness, though I'm using it to make it easier to human read URLs. I can get topic rewriting to work, but not forum or user profile rewriting. Rather, they work, but when I click it takes me to a 404. Vagaries of the mod instead of phpbb itself.
|
# ? Dec 31, 2011 21:29 |
|
I'm not sure if this is totally PHP related, but i think the script im looking for is usually coded in PHP. I'm basically looking for a script that allows user-accounts and the purchasing of credits (usually through paypal) and being able to redeem said credits for various services. Anyone know what im talking about here?
|
# ? Jan 4, 2012 07:32 |
|
I'm a novice in php, but I'm in a situation where I'm having to deal with php and a cake framework. I'm pressed for time, but I find it hard going thru tutorials etc, getting up to speed. I'm trying to parse an element. Right now, every table shows up with a div id of code:
I need to parse that id element to get the row number, so then I can use that row number to get info from a database. Any help or point in the right direction is appreciated.
|
# ? Jan 5, 2012 16:18 |
|
I'm a pretty big novice as well, just spitballing here but can't you just make a DOMDocument and use getElementById to search for the ID of whatever element that is? e; I've never actually used it before, but generally reading the php reference manual it seems like that'd be what you want. Sab669 fucked around with this message at 17:28 on Jan 5, 2012 |
# ? Jan 5, 2012 17:22 |
|
I don't think I fully understand precisely what it is you're trying to do, but this library might be what you're looking for: http://simplehtmldom.sourceforge.net/
|
# ? Jan 5, 2012 18:33 |
|
stoops posted:I'm a novice in php, but I'm in a situation where I'm having to deal with php and a cake framework. I'm pressed for time, but I find it hard going thru tutorials etc, getting up to speed. Are you trying to parse your own PHP-generated HTML using more PHP?
|
# ? Jan 5, 2012 20:16 |
|
qntm posted:Are you trying to parse your own PHP-generated HTML using more PHP? that's what it sounds like to me. seems like he is fighting the framework rather than writing decent code
|
# ? Jan 5, 2012 20:30 |
stoops posted:I'm a novice in php, but I'm in a situation where I'm having to deal with php and a cake framework. I'm pressed for time, but I find it hard going thru tutorials etc, getting up to speed. What's there to parse? You already have the row number, it's $rowCount.
|
|
# ? Jan 5, 2012 21:01 |
|
fletcher posted:What's there to parse? You already have the row number, it's $rowCount. Hmmm. Sorry about this, I'm not explaining myself well. I'll try to make a dummy example. First page spits out Schools, alot of them. Every school is in its own div with number. Beside every school, i have a plus sign you can click on to get more specific data for the school. When i click the plus sign, the specific school data is retrieved via ajax. My problem is, I want to grab the element, "Div-node-NUMBER", and ONLY grab the NUMBER. With that number, I can then tie it to the specific school and grab only that data for that school when the ajax is called. If I use the %rowCount? at the start, wouldn't that grab the data for every school right away?
|
# ? Jan 5, 2012 21:22 |
|
stoops posted:Hmmm. Sorry about this, I'm not explaining myself well. So each school has its own plus button? Why do you need to grab the number from the div? Couldn't you just pass it in the onclick event that you call from the button? edit: So your plus button would be something like code:
Null Set fucked around with this message at 21:28 on Jan 5, 2012 |
# ? Jan 5, 2012 21:25 |
|
stoops posted:Hmmm. Sorry about this, I'm not explaining myself well. code:
|
# ? Jan 5, 2012 21:34 |
|
Thanks guys, I'm gonna try the jquery one. Now I'm in a new problem, which I think should be fairly easy, but I dunno. Every school has a certain number of Images associated with it. I'm currently retrieving the data, and it shows as follows. code:
|
# ? Jan 5, 2012 22:46 |
|
This thread seems like the perfect place to ask. I'm trying to make a website using HTML, SQL and PHP that stores blog posts on a database to be shown on the home page. I'm using PHP because XML doesn't work well with google chrome. I've uploaded what I have so far to a hosting service called https://www.freehosting.com and I want to know where my code, or file locations are going wrong. I have a few visual aids here: This is showing that even though it is trying to reference a database none are showing up in this tab: This is the file 'structure' (where they are in relation to each other) on freehosting's server: If this is too detailed, or if it should be in it's own thread please let me know, but the programs I use aren't telling me exactly what the problems are. For know the code should have printed the text "Test Post" at the top of the page (to make sure the connection works. Here's the link to the site itself: http://gameperspective.freehosting.com/home.html BioEnchanted fucked around with this message at 06:54 on Jan 7, 2012 |
# ? Jan 6, 2012 22:28 |
|
PHP is only invoked when the file is named with the .php extension. PHP isn't parsed in .html files. Your site's main page should also be called "index", not "home". Rename "home.html" to "index.php" and you will see things work. Second, you just posted your password. You'll want to fix that. Third, whatever resource you're using to learn PHP is teaching you to use the terrifying, decrepit mysql extension family of functions. They are effectively worst practice and you should not ever use them for new code, even as a newbie. Especially as a newbie. Throw away the thing that's teaching you to use those functions and never look at it again. Instead, you'll want to learn how to use PDO to access databases. Google for introduction to pdo and you'll find a few dozen worthwile introductory articles, most of which seem to not suck. Read'em all. (Oh, and if your free hosting doesn't have PDO installed... well, it's worth what you're paying for it.)
|
# ? Jan 6, 2012 22:36 |
|
McGlockenshire posted:Second, you just posted your password. You'll want to fix that. Did he? I just see ********
|
# ? Jan 6, 2012 22:41 |
|
BioEnchanted posted:This thread seems like the perfect place to ask. I'm trying to make a website using HTML, SQL and PHP that stores blog posts on a database to be shown on the home page. I'm using PHP because XML doesn't work well with google chrome. I've uploaded what I have so far to a hosting service called https://www.freehosting.com and I want to know where my code, or file locations are going wrong. I have a few visual aids here: First of all, that's not how databases work. You need to be running MySQL or something similar. They don't work if it's just an SQL file. And your PHP code isn't running at all, and read the posts above you. They'll help with the PHP issue, BRO
|
# ? Jan 6, 2012 22:53 |
|
If you're trying to make a blog, why not just use Wordpress, or literally any other CMS? Why are you doing this from scratch when the tools exist that do most of the heavy lifting for you, and won't result in your shoddily designed application getting rooted and destroyed?
|
# ? Jan 6, 2012 23:24 |
|
|
# ? May 15, 2024 17:45 |
|
Weeee, another refresh of PHP image hosting script. I'm sure these things always end up completely non-portable. It seems a fair bit of effort to create a nice phar based installer though, especially something to manage HTTPD configuration, etc. HTML 5, drag & drop, multi-file upload, i18n, public or private hosting. http://junko.hk/junko-php-2.0.tbz2 Requires PHP 5.2+ I think, Pear::Auth is probably a bigger problem for most, GD or ImageMagick works fine, uses Google CDN for jQuery. Missing progress on HTTP downloads, probably a good target for something OTT like websockets. Not the best progress indicator on multi-file uploads, requires some thinking about. Limited informational error messaging. No demo site as I don't have the disk space, sorry. (edit) Looks like Chrome can breakpoint DOM changes so I've grab Picasaweb's progress indicators, also have some bijection code so will look at a non-DB based implementation. Bijection allows for shorter links. MrMoo fucked around with this message at 05:46 on Jan 7, 2012 |
# ? Jan 7, 2012 05:14 |