|
Soks posted:Edit: This one even works on IE 6.0, amazing. I actually know my way around Java code decently, just never used it for anything web based, so I'm pretty confident I can get the code here to do exactly what I want... with only a little help. It's JavaScript, not Java. I'm sure you can still figure out how to work with it, but the difference is not trivial.
|
# ? Nov 24, 2009 04:33 |
|
|
# ? May 19, 2024 10:40 |
|
I need some help here. I was assigned a project where I need to fix a sort by feature on a web page. I know what the problem is - a variable is not receiving the input I feed to it. My question: Anyone know of a good debugger to use with PHP? I need to be able to trace what is happening as the scripts run. What happens is: 1.) Initial home script runs 2.) Home script loads two product info scripts 3.) The product info scripts load templates and other stuff This whole thing is a nightmare. I need to be able to track what the script is doing, be able to pause it, etc. I remember when I dabbled in Ruby, Apatana had a sweet debugger you could use to set break points, step through the execution line by line, and see all variables at once at any time. Does any such equivalent exist for PHP? I'm at my wits end here. This project is so massive that tracking the flow of this is drat near impossible!
|
# ? Nov 24, 2009 16:44 |
|
I like NetBeans and xdebug. You'll need authority over the webserver you're working with, so I recommend running your project locally. Also, print_r all over the place.
|
# ? Nov 24, 2009 16:55 |
|
Just checked out the NetBeans webpage and whoa, this sounds like what I need!NetBeans download page posted:You can inspect local variables, set watches, set breakpoints, and evaluate code live Perfect! Can't wait to try this out! Thanks
|
# ? Nov 24, 2009 17:28 |
|
Speaking of which, what's people's opinion around here with regards to netbeans? I'm a big fan, it's so much less effort than eclipse was to set up and use, but I'm told it's less powerful. EDIT: For PHP development, obviously. josh04 fucked around with this message at 02:17 on Nov 25, 2009 |
# ? Nov 25, 2009 01:53 |
|
josh04 posted:Speaking of which, what's people's opinion around here with regards to netbeans? I'm a big fan, it's so much less effort than eclipse was to set up and use, but I'm told it's less powerful. I love NetBeans for PHP, but I find it also does great stuff for Java, C, and Ruby. I don't like to use it as a database frontend, though. I also love the CSS editor and the JavaScript hints that tell you about browser compatibility.
|
# ? Nov 25, 2009 02:37 |
|
Is it possible to write a php script on one server that creates files on another server without the use of ftp?
|
# ? Nov 25, 2009 06:48 |
|
smith7800 posted:Is it possible to write a php script on one server that creates files on another server without the use of ftp? Yes, multiple ways. I would use one of these two: Sockets - basic client/server model with the client requesting the server save the file - http://php.net/manual/en/book.sockets.php Route through a shared database. Looping script checks a database table for entries, then flags/deletes them and creates the file.
|
# ? Nov 25, 2009 06:57 |
|
This isn't a pure PHP question per se, but I hope you guys can help. Basically, I'm working on a system where users own a variety of different items. For the purpose of this example, I'll make an analogy with a shop: Users can own bread, cars or TVs. The table structure is set out such that each item type exists in two tables: `item` and `useritems` (EG: `types_of_bread`, `userbread`) That's all gravy, but each item can have a series of modifiers. Essentially, these can either add stats to the item (for example enhance the car's maximum speed) or change the item completely (bread -> toast) In either case the modification needs two (pseudo)"events" -> "onapply" and potentially "onremove" that fire when the user activates the modification. I am wondering how to implement this. A rather messy solution, would be to put raw PHP in the DB, and eval() it, but that stinks of bad design and potentially horrific debugging. code:
Does anyone have a better solution to this problem. Ideally, I would love to over-engineer the problem by writing my own language :P
|
# ? Nov 27, 2009 23:33 |
|
Fruit Smoothies posted:This isn't a pure PHP question per se, but I hope you guys can help. Serialize can store objects / classes in a db, but I'm not sure that's what you need, because I'm not sure I fully understand your problem. Does one user change ALL bread to toast, or just his own bread?
|
# ? Nov 28, 2009 01:45 |
|
I don't know what to tell you about the database itself, but the classes sound like a task for the decorator pattern.
|
# ? Nov 28, 2009 03:26 |
|
I guess I missed out an important statement: The idea is to make the modifications completely DB-only. I can't have any static code in any libraries. I will look up decorator patterns when I get back from work, and serialize too. EDIT: I've got home from work and the decorator pattern is what I was using. The trouble is, the decorator functions need to be stored in the DB. Potentially, I could write my own little interpreter for mylanguage -> SQL - since the decorations only alter the database - but serialize() or the json_encode function aren't really the perfect option, since storing a function as an array still requires a little too much parsing, probably. There's always bytecode ;-) Fruit Smoothies fucked around with this message at 23:17 on Nov 28, 2009 |
# ? Nov 28, 2009 10:10 |
|
Surely you should be using OOP and having a "bread" class, etc? Putting PHP in the DB is kind of horrible.
|
# ? Nov 30, 2009 12:01 |
|
It is a bad idea to put code in the DB (as you seem to realize). For your own sanity, and the sanity of others who may need to work with your code someday, please permanently remove that from your list of options. You should explain a little bit more on the problem you are trying to solve. Whats the big picture? Whats your class structure, why does this need to be in the DB? The examples thus far have been a tad confusing. If it absolutely must be in the DB perhaps you can use, or develop, some sort of XML rules engine. code:
|
# ? Nov 30, 2009 17:02 |
|
Creating your own horrifying xml-based DSL and sticking that in the database is still putting code in the DB.
|
# ? Nov 30, 2009 17:06 |
|
Well it doesn't NEED to be in the database per se, but it makes add / removing new modifications a lot easier than creating static code for each modification. It's for a game which requires a system whereby any item / statistic is able to be modified. There is also future room for development where other users may be able to create their own modification. I guess an array (JSON) / XML structure is slightly less messy than an eval()'d PHP solution.
|
# ? Nov 30, 2009 18:42 |
|
Fruit Smoothies posted:Well it doesn't NEED to be in the database per se, but it makes add / removing new modifications a lot easier than creating static code for each modification. You might think its easier to put it into a DB, however what about changes? What you if you have 2000 items that all call the RemoveItem() function. Then lets say you decide that you have to add a third argument to that function? Now you are going to have to edit 2000 database items and modify that function somehow. Sounds like a shitstorm. Not to mention the enourmous security holes that could be present there, especially if users can make changes. Same thing as storing XML rules in a DB as Plorkyeran stated. What if your XML structure changes? Its not like you can just apply some simple transform to a bunch of files. Really your database should be just for storing data, not any kind of logic or anything like that. That should all be outside the db. If I were you I would hard code all your classes and functionality, get your game working, then try to tackle this problem after the fact, when you really need this feature. Like its a good idea to keep in the back of your mind that you want users to be able to edit this stuff, but if its not a requirement for v1.0, then don't waste your time on it until you really need it. If you have logic stuff in database records, you are going to regret it. Its going to be like that one fat girl you brought home from the bar and woke up next to and wish you could forget, but then you keep seeing her around town and every time it makes you cringe. Personally I would rather create a bread class and a toast class than have to deal with all these headaches.
|
# ? Nov 30, 2009 19:28 |
|
Fruit Smoothies posted:Well it doesn't NEED to be in the database per se, but it makes add / removing new modifications a lot easier than creating static code for each modification. Then create some sort of event class and have a bunch of preset things that they can do. You can't have users modifying PHP code. Full stop. Eval-ing PHP from the database is a horrific idea. If the events are within the game, then perhaps your own in-game scripting language type thing would suffice, as it would create an abstraction and prevent players touching the PHP. However, unless you knew what you were doing, I'd very much recommend that you avoid giving users too much power, especially in PHP. Why is modifying static code difficult if you have it version controlled and deployed from a SCM? Also, read into abstract classes, etc. So you could have class bread extends food, or class spoon extends weapon or whatnot.
|
# ? Nov 30, 2009 20:54 |
|
I would never be foolish enough to let the users have access to the raw PHP. I am waiting for a fellow goon to do the artwork, so I thought I might-as-well get the database as perfect as I can in v1. As for the function params changing, this isn't likely to happen. The DB fields are going to be the inner code for a function, and thus any parameter changes will be done in the hard code. As for the solution, I think an array based structure is a good idea. XML is a little too long-winded really, so I think I'll just go with array=>JSON code:
I hope you don't slate me too much for this choice.
|
# ? Nov 30, 2009 21:04 |
|
You could use the string-as-function feature to call your PHP code based on a function name stored in the database. I realize that's horrible, but it's less horrible than storing an entire function there.
|
# ? Nov 30, 2009 21:45 |
|
josh04 posted:Speaking of which, what's people's opinion around here with regards to netbeans? I'm a big fan, it's so much less effort than eclipse was to set up and use, but I'm told it's less powerful. I'm liking it a lot on my Mac for larger scale projects. Being able to type $myObject-> and have it pop up a list of all the methods (with PHPDoc comments included), even when the class is defined by a file in a separate directory, is pretty sweet. I always had a distaste for Java apps and NetBeans seems a little overkill/bloated when working on smaller one-off scripts so I still find myself using TextMate when I need to do something quick like make a minor change to a remote file over SFTP. I used TextMate as my only editor for a long time but now I find that I miss a lot of the code hinting/debugging stuff from a real IDE like NetBeans whenever I try and work on those sorts of projects in TextMate. It's sort of jarring having two main editors with all different shortcuts and navigation keys, though, so I may just end up sticking to TextMate and missing out on some of the niceties from NetBeans. Quick tip for fellow Mac users, you can get Quartz font smoothing and make text look a whole lot better in NetBeans by adding code:
Parker Lewis fucked around with this message at 22:07 on Nov 30, 2009 |
# ? Nov 30, 2009 22:04 |
|
I am in the market for a new job. I know PHP and MySQL very very well. And that's it. This seems to be limiting my opportunities. What do folks recommend as another language to learn while I try to find a PHP/MySQL job?
|
# ? Dec 1, 2009 11:21 |
|
rt4 posted:You could use the string-as-function feature to call your PHP code based on a function name stored in the database. I did contemplate call-user-function() but I think I'm happy with my array structure.
|
# ? Dec 1, 2009 11:38 |
|
Golbez posted:I am in the market for a new job. I know PHP and MySQL very very well. And that's it. This seems to be limiting my opportunities. What do folks recommend as another language to learn while I try to find a PHP/MySQL job? Something heavily object oriented like Java, C++, or a .NET language.
|
# ? Dec 1, 2009 11:39 |
|
If anyone else uses Notepad++ for your PHP development, you might want to avoid 5.6 Matching brace highlighting stopped working consistently for me after I installed it.
|
# ? Dec 1, 2009 23:54 |
|
What's the difference between MYSQLI_USE_RESULT and MYSQLI_STORE_RESULT? The documentation for mysqli_query doesn't explain the difference between them (and when/why one should be used over another), and most places seem to just copy from there.
|
# ? Dec 3, 2009 11:18 |
|
Here's a link that seems to have a good explanation on the differences.
|
# ? Dec 4, 2009 00:04 |
|
Fruit Smoothies posted:I would never be foolish enough to let the users have access to the raw PHP. I am waiting for a fellow goon to do the artwork, so I thought I might-as-well get the database as perfect as I can in v1. I still fail to see why your code needs to be in the DB as opposed to in a class.
|
# ? Dec 7, 2009 01:00 |
Hey everyone. I'm a PHP beginner and I'm trying to figure out how to do a "Read More" link in an article. So I'm pulling in an article from mySQL, and after some length, but not in the middle of a word or anything, I'd like to have it say "Read More" with a link onward. How is this done?? Sorry to ask such a rudimentary question on here, but you can imagine googling "php 'read more'" kinda gives a mixed bag of results. Thanks!
|
|
# ? Dec 7, 2009 05:24 |
|
growing posted:Hey everyone. I'm a PHP beginner and I'm trying to figure out how to do a "Read More" link in an article. So I'm pulling in an article from mySQL, and after some length, but not in the middle of a word or anything, I'd like to have it say "Read More" with a link onward. How is this done?? That's cause you should search for php "read more link" http://programming-in-php.blogspot.com/2009/10/function-to-show-read-more-link-in-php.html That one truncates after x chars, then backs up to the nearest space so you avoid cutting a word in half.
|
# ? Dec 7, 2009 06:32 |
Exactly what I was looking for. Thank you.
|
|
# ? Dec 7, 2009 06:54 |
|
You could also do this using Javascript so the read more link doesn't reload the page, just replaces the contents of the DIV with the response from request that fetches the rest of the article in HTML.
|
# ? Dec 7, 2009 14:43 |
That's good to note, but all I need it to do for now is link to the next page. On another note, what am I doing wrong here?? How can I get the form action to grab the city id # from the function?code:
|
|
# ? Dec 7, 2009 19:17 |
|
Aren't you just missing the word "echo"?
|
# ? Dec 7, 2009 19:47 |
|
OK, I'm avoiding work so here's a possible rewrite.code:
Tad Naff fucked around with this message at 16:51 on Dec 8, 2009 |
# ? Dec 7, 2009 19:52 |
Actually, that whole thing was monumentally wrong.
|
|
# ? Dec 7, 2009 20:38 |
|
Why do you have functions in your loving HTML seriously what the gently caress? You should probably look into organising your code before you write another line. HTML goes in templates (with minimal PHP for things like loops and variables), functions go in logically grouped function files that are included (if you're going with a procedural approach for some reason). You do not use the ancient mysql extension, you use PDO because it is sane and has nice prepared statements. Being a beginner is no excuse now that there is such emphasis on writing clean, maintainable code. Rat Supremacy fucked around with this message at 13:43 on Dec 8, 2009 |
# ? Dec 8, 2009 13:38 |
|
I need some help. Im overhauling my company's website, and i've been re-making everything from scratch so far. The only thing I don't have the knowledge to re-make is the store locator, cause its written in php (of which i have no base of understanding). So right now Im just linking the old store locator into the new site, which is fine temporarily. The problem is, I cant figure out how to style the old locator to make it match the new site because it uses some style template written in XTPL, and I cant find any documentation about it. So, is there someway around this? Or do I have to salvage the old data, make a new one, and teach myself php in the process? This is the site: old: https://www.bergfurniture.com new: https://www.bergfurniture.com/new_site.asp store locator: https://www.bergfurniture.com/storelocator/store_locator.php
|
# ? Dec 9, 2009 15:41 |
|
DirtyDaub posted:The problem is, I cant figure out how to style the old locator to make it match the new site because it uses some style template written in XTPL, and I cant find any documentation about it. I hate to be that guy, but it took me two seconds with Google to find that XTPL refers to PHP XTemplate. That's a link to the docs.
|
# ? Dec 10, 2009 05:48 |
|
|
# ? May 19, 2024 10:40 |
|
haha, yeah my bad. I actually did find that site a while ago but couldn't really understand what any of it meant. After staring at the examples for a little bit longer I started the get it. The main problem was I couldn't figure out how to edit the xtpl file (dreamweaver doesnt recognize it), but I played around with it and found out I can open it up and edit it in notepad. problem solved. Thanks for the help.
|
# ? Dec 10, 2009 15:15 |