|
Excellent call on the thread. PHP Frameworks: what lots of us use is: CodeIgniter A PHP5 only alternative: Kohana Link to the CodeIgniter Thread
|
# ¿ Mar 19, 2008 20:51 |
|
|
# ¿ Apr 29, 2024 11:46 |
|
Super 3 posted:Dont have access to the php.ini over here. code:
|
# ¿ Mar 21, 2008 21:26 |
|
nbv4 posted:
Or you could add ' MAX(myValue) as theBiggest ' to your query and have it available in each row already....
|
# ¿ Mar 22, 2008 15:51 |
|
Kaluza-Klein posted:I want to parse an html file. For example, say I want to know what is contained inside an <h1> tag. I can do this with strstr and substr but it is ugly. If you are using PHP5, and your HTML is valid XML (which it might (probably?) not be) you can do it easily like so: php:<? $xml = simplexml_load_file('myHTML.html'); echo $xml->h1; ?> Otherwise check out the DOM and XML methods in the manual, they are pretty self explanatory.
|
# ¿ Mar 22, 2008 15:58 |
|
Gary the Llama posted:I've just playing with CodeIgniter and have already ran into a problem. I'm trying to load a model from my controller and I'm getting this error: The Loader.php file contains the code that is run when you do $this->load->whatever() so that is why it's showing you the error there. My guess is that there is an error in your Model that is keeping it form being run as a class. Replace your code with this: php:<? class Test_model extends Model { function Test_model() { parent::Model(); } } ?>
|
# ¿ Mar 25, 2008 14:27 |
|
chips posted:Question about PDFs: Google found this: http://www.webmasterworld.com/forum88/898.htm which has someone trying to do the same, and info on how to do it. Requires imagemagick, looks like.
|
# ¿ Apr 2, 2008 02:30 |
|
Safety Shaun posted:Without setting a cookie, session or global variable, I need to pass a variable from index.php to a PHP script included as an image. This is technically what you asked for :P php:<? [code] $inIndex = 'true'; echo "<img src='showImage.php?param1=yay¶m2=wee&inIndex=$inIndex'>"; ?> php:<? // showImage.php if ( isset($_GET['inIndex']) && $_GET['inIndex'] == 'true') { //show real image }else{ //show fuckoff.jpg } ?> Lumpy fucked around with this message at 03:33 on Apr 17, 2008 |
# ¿ Apr 17, 2008 03:30 |
|
Jimix posted:For some reason I cannot remember how to do this, or at least I swear that I had to do this for that PHP class I took a few years back... If I am understanding you, you do not want PHP for this, you want javascript. code:
|
# ¿ Apr 21, 2008 20:51 |
|
Zorilla posted:Triple-equals signs always weird me out. Since we're evaluating the success/failure of a variable assignment, is your example the same as this? No, because if you are at position 0, it can be evaluated as false, and your expression will return true, and you will see "not found" Learn to love triple equals and it's pal !==
|
# ¿ Apr 23, 2008 03:00 |
|
awdio posted:I was using php code to check if a sent $_GET didn't come from outside of my website. Now I want to do the same thing with $_POST, and I expected the code to work for it, but it doesn't do anything inside the if statement if a $_POST occurred. I tested to make sure this was the case by echoing the sent $_POST outside of the if statement, which works. Hmm, I'm stumped on that one, but as a quick check, try this: php:<?php $tmp = strpos(strtolower($_SERVER['HTTP_REFERER']), 'mywebsite.com'); echo "My test returned: ".$tmp; if ($tmp !== false){ echo $_POST["sentVar"]; }else{ echo "Hey, my test failed! ".$_POST["sentVar"]; } ?>
|
# ¿ May 2, 2008 22:36 |
|
[edit] never mind. Didn't see the crazy "my script doesn't know what I am sending it" caveat.
Lumpy fucked around with this message at 02:58 on May 12, 2008 |
# ¿ May 12, 2008 02:56 |
|
Zorilla posted:Then shouldn't it be like this? Why would you put the top and bottom PHP tags in there? I vote be really lazy: code:
|
# ¿ Aug 10, 2008 03:05 |
|
Hammerite posted:I see, I guess if that could be a worry then I ought to go find out how to move the file containing database account information to a safe location. Thanks. It's pretty easy.. if your web root is at /var/apache/htdocs/ for example, then store your important stuff in a new folder like /var/apache/hidden/ and then include of the full path to the files: php:<? require_once('/var/apache/hidden/top_secret_db_info.php'); ?>
|
# ¿ Oct 13, 2008 14:51 |
|
Hammerite posted:So the include statement now reads The only "problem" with that is when you move your including page to a new level in the directory hierarchy. Then "../../" points somewhere else, and everything breaks. Try to use absolute paths as much as possible. But if it works for now, then you done good, and keeping passwords / usernames, etc. outside of web root is always a good thing, no matter how you go about doing it.
|
# ¿ Oct 13, 2008 22:42 |
|
Zorilla posted:It seems cheesy to hardcode the absolute path to files for one particular server. Is there a way to acquire the web server's DocumentRoot path so things can be easily moved from server to server? php:<? $dr = $_SERVER['DOCUMENT_ROOT']; ?> Lumpy fucked around with this message at 14:38 on Oct 14, 2008 |
# ¿ Oct 14, 2008 14:31 |
|
Sparta posted:I have this: Why don't you use $_SERVER['HTTP_HOST']; to get the host? No parsing required. [EDIT] Try printing $purl with print_r($purl) and see if it's actually setting a host to see if it's the parsing or something else.... Lumpy fucked around with this message at 01:47 on Oct 15, 2008 |
# ¿ Oct 15, 2008 01:45 |
|
Sparta posted:Returns Array ( [path] => https://www.mikemanfrin.com/hello ) I do not know much (read: anything) about parse_url. Could it be because it does not have 'http://' in front of it? If *none* of your url vars are going to have [url]http://[/url] in front of them, why not use explode() and then grab the first element of the resulting array?
|
# ¿ Oct 15, 2008 19:54 |
|
J. Elliot Razorledgeball posted:
Syntax error on that line.
|
# ¿ Oct 17, 2008 16:14 |
|
simcole posted:I had a friend write me some code. I don't understand what -> does. Can someone link me an article and explain it? -> is the equivalent of the "." in most languages. An English translation would be " method or property of " an object. $blah->talk(); is like "call the talk() method of the $blah object" and echo $pie->flavor; is "echo the flavor property of the $pie object" $this is a self-reference. If I have code inside an object, $this refers to the object said code is running in.
|
# ¿ Oct 17, 2008 19:53 |
|
H0TSauce posted:Shouldn't you be escaping your php variables from the sql string? If it's inside double quotes, "simple" variables will be replaced. Complex ones (array values, object properties) would need to be escaped, but not here.
|
# ¿ Oct 21, 2008 19:08 |
|
fletcher posted:Use PDO so you can just write nice clean SQL statements, and you never have to worry about escaping a variable again. (this needs to be in the OP, this comes up time and time again) I assume PDO cleans bound parameters of nasties, or must one still do that manually?
|
# ¿ Oct 23, 2008 20:25 |
|
Hammerite posted:
Can you indicate to us which line is line 36 in your code?
|
# ¿ Nov 7, 2008 22:20 |
|
Rsugar posted:Hey, I'm developing the framework for a small php/flash combo game. Pass the session number (or username, or whatever) to Flash as a parameter when you embed the object. Then flash can use it as part of it's data requests.
|
# ¿ Nov 11, 2008 21:30 |
|
Lankiveil posted:What is the current cool framework to use for PHP? At the moment I'm playing with CodeIgniter, but I'm happy to jump ship if there's something better out there. I'm a CodeIgniter guy, mainly because I started using it because I had a site that was still on PHP4. I really like it, and recommend it. I looked at Kohana ~6-8 months ago, but the documentation was very lacking back then. If they have improved that, and you are on PHP5, I would recommend it as well, as it is faster / more modern.
|
# ¿ Nov 21, 2008 16:57 |
|
Chinaski posted:As a follow up, I found a simple "suggestion" script on the server: The script you have there assumes GLOBALS is on... which 99% of the time it isn't. You;ll need to extract the $message from the POST or GET (your form doesn't specify an action, so it whatever your server defaults to) php:<? $message = $_POST['message']; ?>
|
# ¿ Nov 21, 2008 21:59 |
|
Emo.fm posted:Just started with PHP, trying to write a form handler that will take some input from a POST form and write it to a text file. I can do the whole fopen, fwrite, fclose etc kind of thing when there's no form involved, but as soon as I use a form to execute the handler (even using the exact same code), I get permission denied. I know this isn't strictly a PHP question, but is there something about executing from a form instead of accessing the .php file directly that affects my file permissions? How can I get around this? It's crapping out before it even gets to the POST bit, so it doesn't look like that's the problem. You are *sure* it works w/o the POST? It won't change if the page was just loaded, or if it was sent POST data. Replace $_POST['song'] with "lolz" and see if you get the same error when you load the page.
|
# ¿ Dec 21, 2008 23:37 |
|
Zorilla posted:
NULL is evaluated to FALSE, but your context there is a bit odd. The assignment of "something" to $target will be TRUE, even if it's NULL because there's no $source left. My guess (not knowing exactly what you are trying there) is you want foreach php:<? foreach ($source as $value) { // do stuff } ?> Foreach: http://us3.php.net/manual/en/control-structures.foreach.php
|
# ¿ Jan 7, 2009 06:38 |
|
awdio posted:This is a mixed php/Actionscript 2/MySQL question. PHP is echoing back a variable queried from MySQL just fine, called $imageSourcesString. When gets the variable with loadVariables, it returns empty in Flash. If I redefine $imageSourcesString in php as $imageSourcesString="test"; its sent to Flash just fine. It needs to be a URLecoded string... your problem seems odd though. Are you trying to output the string $myVar=A[$myvar's value]A as a result? [EDIT] looks like you *can* use an "$" as the first char of a variable name in AS2, but I'm guessing the URLencoding is hosing it up still. Lumpy fucked around with this message at 22:15 on Jan 7, 2009 |
# ¿ Jan 7, 2009 22:07 |
|
awdio posted:I guess the question I should be asking is: How do you pass a variable with GET from one page to another (or even the same page) and have Flash load that variable in? I'm just passing it with the same page, but I've also tried passing it to another page. PHP gets it. Flash does not. If I just make a non-POST or non-GET variable it passes to Flash fine. I'm confused now. Are you loading a page: blah.php?var=value And you want the flash that is embedded on the page to know that var = value? Or you are using flash to send a request to a script after your page loads, and the return from the script is var=value and flash is unable to pick that up? awdio posted:I'd try WireShark, but I don't think there's a non-Intel Mac version. open up terminal and use tcpdump Lumpy fucked around with this message at 22:09 on Jan 9, 2009 |
# ¿ Jan 9, 2009 22:05 |
|
awdio posted:Works like this: Can you give us a real URL. I think I know what your poblem is, but I can't be sure unless I see WTF.
|
# ¿ Jan 9, 2009 22:38 |
|
awdio posted:Yes. And I can get a php variable into Flash. Its the GET variable in a mysql query is what causes things to get hung up. If I define the variable without the GET, it does not happen. I can echo back the correct results of the php query, the Flash just does not get anything from the result of the query. How is the Flash supposed to get the stuff you generate to the hidden field? Magic? Why not tack on your vars to the end of the URL to the movie? code:
|
# ¿ Jan 12, 2009 19:32 |
|
awdio posted:Flash can get the stuff on the hidden field perfectly fine except when the initial variable from GET that SQL uses for a query is used. If I just simply defined the variable instead of using the value of GET everything would be fine. I'd explain how this works all over again but I've explained this in at least 3 other replies so far. Read those so you can understand what the problem is more. But thanks for your suggestion I'll try that. Your replies are confusing at best. "Flash can get stuff out of hidden fields" doesn't make any sense whatsoever. Good luck finding a solution, but you've baffled me beyond the ability to try to help you any more
|
# ¿ Jan 13, 2009 16:15 |
|
awdio posted:Flash actionscript can use loadVariables("currentpageURL.php", this, "POST"); to get POST variables from the current page that it is on. You can make the value of hidden fields like so to make a POST variable like so: You realize it doesn't "look at the current page" right? It actually sends a request to the server for the script, and loads it in again. That's your problem. Do what I suggested, since what you are doing makes no sense whatsoever. Lumpy fucked around with this message at 20:24 on Jan 13, 2009 |
# ¿ Jan 13, 2009 20:19 |
|
Tots posted:This should be trivial for anyone with more programming experience than me... php:<? echo "<hr> Please specify which file to display"; echo "<form action=\"index.php\" method=\"get\">"; echo "Name of file: <input type:=\"text\" name=\"fileToOpen\" />"; echo "<input type=\"submit\"/>"; echo "</form>"; if(isset($_GET['fileToOpen')) { $openMe = $_GET["fileToOpen"]; if( $file = fopen("$openMe" , "r") ) // holy security hole! { echo "<center><table border=\"1\">"; while (!feof($file)) { echo "<tr><td>" . fgets($file) . "</td></tr>"; } echo '</center></table> You have reached the end of the file<br />'; fclose($file); } else { echo "no file"; } } ?> [edit]\/ Yes, that is is. you can enter '/etc/passwd' in your form or something else as nefarious. Lumpy fucked around with this message at 20:20 on Feb 20, 2009 |
# ¿ Feb 20, 2009 19:16 |
|
TreFitty posted:I'm learning PHP and was wondering: can you guys recommend any of the frameworks in the original post? I mean, does one completely outclass the other? Which is better for what? etc. CodeIgniter. But as gibbed said, your needs will dictate what you use, because they all have strengths and weaknesses. If you are just learning PHP, I'd suggest not using one for a while, until you notice you are writing the same bits of code (DB access, login handling, etc.) over and over. Then it's time to shop for a framework. Sure, you can walk into the dealership and buy a new car, but if you tinker with that old junker and get it running yourself, you'll know what's going on under the hood.
|
# ¿ Mar 11, 2009 06:27 |
|
KuruMonkey posted:I'm not going to say you're wrong, Lumpy. But the other way to look at is that a framework can act like the stabiliser wheels on a bike while you learn to ride. As I was typing up my reply, part of my brain was saying "yeah, but think of all the time you could have / would have saved had you started using one right away." I stuck with my guns though, because say you do use framework X to learn. Later on, you interview for a job that doesn't use one, or some hot chick wants you to fix her image gallery script for her pretty pony website, and will pay in sex but it doesn't use the framework you learned PHP on. You now have to spend the time learning stuff outside your comfort zone which can be harder once you've established a habit... "Wait, there's a *different* way to make DB connections other than $this->load->db() ???" If you learn with training wheels, and there is no incentive to ever take them off, if somebody presents you with a new bike that doesn't have them, you may be baffled. I do see your point, and I don't think learning *with* a framework is bad by any means, but having the motivation to go outside of it and look through it's source and so forth would be essential in my opinion.
|
# ¿ Mar 11, 2009 15:45 |
|
gibbed posted:And for the love of god use .php as the extension, not .inc, or at least .inc.php. How will others learn from your mistakes if that can't view your raw, unparsed code via the web?
|
# ¿ Mar 12, 2009 14:18 |
|
eHacked posted:Hi, thanks, changing the constructor name seemed to work... would this have anything to do with the server I'm learning off of running php 4? Yes. PHP4 doesn't do __constructor
|
# ¿ Mar 24, 2009 15:53 |
|
Dolemite posted:
Where is the javascript? If there is no javascript, well, there is your problem. I have no idea what you are trying to accomplish in that onclick, but it certainly isn't valid.
|
# ¿ Mar 24, 2009 22:29 |
|
|
# ¿ Apr 29, 2024 11:46 |
|
royallthefourth posted:What is this called? heredoc [edit] now with link! http://us2.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc
|
# ¿ Mar 30, 2009 22:25 |