|
KuruMonkey posted:I would make that string be constructed on one line, and check the error line changes; I suspect your error isn't in that line at all. It certainly was not, and I am no longer confused. Essentially, I gave up on the mod because it royally messed up the formatting of the entire forum. Thank your for all the help.
|
# ? Jan 25, 2009 03:51 |
|
|
# ? May 16, 2024 14:04 |
|
Oh god my current job is driving me nuts. The place I started working for has a loving *massive* inhouse CMS , and its atrociously written. You know the sort. Load in the chrome, ?action=xxxxxxx include (getIncludeFile($_GET['action'])); blah All procedural. Theres a custom database layer that doesn't seem to understand cursors and cant do prepared statements. On the upside, it has smarty, which is something I guess, since its a 40 man dev team. Or is it? One of the sites had a smarty template with about 4-5 thousand lines of smarty conditional template logic mangled with javascript that generated custom javascipt to deal with some poo poo that was all if product='aaaa' then bbbbbbb else if product = 'bbbb' then ccccc else if pro<blah> for thousands of lines. gently caress PHP with a rusty screwdriver. It encourages some *horrifying* coding sometimes.. I'm dying for a django job here folks.
|
# ? Jan 25, 2009 18:19 |
|
Don't blame the tools; blame the Tools using the tools.
|
# ? Jan 25, 2009 21:41 |
|
I have the problem where a regular text input two word value is being passed into a hidden input but one one word coming out of it. Like this Page 1 text input box containing "two words" Page 2 picks up "two words" from text input box, displays "two words" as text and stores "two words" in a hidden input. Page 3 Displays "two" from the hidden input instead of "two words" This is what I'm using as the hidden input line: code:
code:
|
# ? Jan 25, 2009 23:07 |
|
Add quotes around the second input's value attribute.
|
# ? Jan 26, 2009 08:20 |
|
supster posted:Add quotes around the second input's value attribute. I did, I did it without quotes and with quotes. Even with quotes it didn't pass the values through. I might as well pass all this stuff through through sessions, can you see a downside to using sessions to pass through about 25 values?
|
# ? Jan 26, 2009 13:06 |
|
You're only showing us half the party. Show us the code from page 2 that stores the post value as $address_line3. Is it a simple assignment? "$address_line3 = $_POST['address_line3']"? I've never had any problem with text input boxes sending only one thing... Also, is the name of the text input box "address_line3", or are there any [] brackets in it?
|
# ? Jan 26, 2009 18:11 |
|
This sets the hidden valuecode:
code:
Should I dismiss the idea of passing data through multiple hidden values or should I go through sessions?
|
# ? Jan 26, 2009 20:17 |
|
Cad_Monkey2 posted:Should I dismiss the idea of passing data through multiple hidden values or should I go through sessions? php:<?php echo "<input type='hidden' name='address_line1' value='".$address_line1."' />"; ?> php:<?php // code ?> <input type="hidden" name="address_line1" value="<?php echo $address_line1; ?>" /> <?php // more code ?> Zorilla fucked around with this message at 20:46 on Jan 26, 2009 |
# ? Jan 26, 2009 20:31 |
|
Cad_Monkey2 posted:This sets the hidden value Install the Live HTTP headers firefox extension and see if the value for "address_line1" is being sent at all. If it isn't, there's probably a naming problem. If it is, then try echoing it directly onto the page to see if the value is being assigned to $address_line1 correctly. If it is, continue with more debugging. This is really one of those times to refine your debugging skills. There are a lot of ways that you could figure out what is wrong.
|
# ? Jan 26, 2009 20:34 |
|
Does anyone have a decent PHP-based directory index generator? I've stolen a few off websites, and they all suck, and I'm too green at this to do a decent job myself. Our server admin turned off index generation, which is fine, as a lot of our filenames are long enough that they're truncated with a standard server generated index, which isn't desirable in this application. Something simple that just shows Filename, denotes [directory names] differently, shows file size, maybe file date, and can sort columns, and is smart enough not to list index.php. I don't know, I figure this has to be common enough that someone has created a nice one.
|
# ? Jan 26, 2009 23:47 |
|
Civil posted:Does anyone have a decent PHP-based directory index generator? I've stolen a few off websites, and they all suck, and I'm too green at this to do a decent job myself. They're so easy to write with DirectoryIterators that you could probably manage it yourself. http://us.php.net/manual/en/class.directoryiterator.php
|
# ? Jan 27, 2009 01:53 |
|
I'll be testing sonic bed head and Zorrilla's replies tonight but I've pretty much abandoned the idea of sending stuff through hidden inputs and switching to sessions instead. Cheers guys. Zorilla posted:(which I would recommend since using echo statements to output HTML produces really lovely code) Do you mean it produces lovely HTML code or just hard to read php code?
|
# ? Jan 27, 2009 11:59 |
|
Cad_Monkey2 posted:Do you mean it produces lovely HTML code or just hard to read php code? 2. IDEs ignore HTML inside of PHP tags, so forget syntax highlighting, block folding (instantly skipping past divs or tables), and DOM error feedback (forgetting a closing tag or some other HTML syntax error). If you don't know what these are, try Eclipse. Internet Headache fucked around with this message at 12:54 on Jan 27, 2009 |
# ? Jan 27, 2009 12:52 |
|
Right, I've downloaded the All-in-One Eclipse PDT + Zend Debugger Package and I'll be having a play with that while reviewing and simplifying my code tonight, thanks for the help Internet Headache. I've got loads of php pages to write so I'd rather iron out these problems and get into 'best practice' while in the early stages.
|
# ? Jan 27, 2009 13:38 |
|
Cad_Monkey2 posted:Do you mean it produces lovely HTML code or just hard to read php code? Both. You end up with a whole lot of the word "echo" in your PHP and the HTML output likely won't be tabbed properly, and if you didn't litter your code with "\n" all over the place, the output will likely all on one line too. If you want to assign large blocks of HTML to variables, either use output buffers or heredoc statements (I recommend the first since it will keep your HTML context highlighted in most editors). Zorilla fucked around with this message at 14:04 on Jan 27, 2009 |
# ? Jan 27, 2009 13:47 |
|
You've pretty much hit the nail on the head here, Zorrila. Echos and \n all over it with the added benefit of sometimes forgetting to end the php line with ;. The actual html output (code wise) looks pretty good though. Oh well, as I said, I'd rather find this stuff out at the beginning of a project than at the end. Cheers for the advice everybody.
|
# ? Jan 27, 2009 13:59 |
|
I have inherited a web server from someone else at work and up till now all websites have been developed using asp .net I only know php so I plan to install php on the web server but I am totally paranoid that doing so will cause the asp.net driven web applications to stop working. Can anybody reassure me this is not the case or point me in the correct direction for more reading? Is this thread the best place to post this I wonder? MeTa_Cunt0rV2.1 fucked around with this message at 15:49 on Jan 27, 2009 |
# ? Jan 27, 2009 15:46 |
|
Just do a Google search for "Install PHP IIS <IIS version number>". You can definitely run ASP.NET and PHP together on the same server peacefully.
|
# ? Jan 27, 2009 15:53 |
|
Thanks, just wanted to make sure. I knew I was being paranoid but I've been stitched up so many times by thinking "things will be fine if I do this..."
|
# ? Jan 27, 2009 16:05 |
|
Civil posted:Does anyone have a decent PHP-based directory index generator? I've stolen a few off websites, and they all suck, and I'm too green at this to do a decent job myself. I wrote one of these once http://r0klist.sf.net/ it's all procedural and has echos all over but I don't give a gently caress!
|
# ? Jan 27, 2009 21:06 |
|
Is this legal?code:
code:
|
# ? Jan 28, 2009 04:59 |
|
It's certainly legal but it isn't doing what you're hoping it is doing Golbez posted:
The statement inside of the inner-most parenthesis is interpreted first, always resulting in TRUE (see http://www.php.net/manual/en/types.comparisons.php). Therefore, your conditional statement will always be: code:
code:
|
# ? Jan 28, 2009 05:43 |
|
Aha. Thanks.
|
# ? Jan 28, 2009 06:42 |
|
This is being used instead of mysql_real_escape_string. Is there a way to make prepareformysql the same as the real escape string. php:<? function prepareformysql($sqt) { return str_replace("'", "''", $sqt); }?> It is used a bunch of times. Here are two examples. php:<? $to_action = prepareformysql($_REQUEST['to_action']);?> php:<? if(!$dbc->sql_exec("update users set info='".prepareformysql($_POST['info'])."', insert_date = insert_date where id = ".prepareformysql($_POST['user_id'])))?>
|
# ? Jan 28, 2009 19:22 |
|
Can I install pdo_mssql on a PHP 4.x Linux installation?
|
# ? Jan 28, 2009 20:19 |
|
Super Delegate posted:... Easiest would be code:
But the best way would be to see what kind of $dbc object is and hope it supports prepared statements, so you can use them instead.
|
# ? Jan 28, 2009 20:21 |
|
J. Elliot Razorledgeball posted:Can I install pdo_mssql on a PHP 4.x Linux installation? At work I use MSSQL on Linux with PHP5 and I had to compile my own package. It's a huge pain.
|
# ? Jan 28, 2009 20:25 |
|
royallthefourth posted:At work I use MSSQL on Linux with PHP5 and I had to compile my own package. It's a huge pain. Yeah I'm not looking forward to it. Do you have any tips? Is it even compatible with PHP 4.x though?
|
# ? Jan 28, 2009 20:35 |
|
I've never even used PHP4 before, but I followed these instructions which helped me a great deal. http://panthar.org/2006/06/15/php-with-mssql-on-ubuntu-606/
|
# ? Jan 28, 2009 20:40 |
|
Is there a good way to handle nodes with perios in their names when using simplexml?code:
|
# ? Jan 29, 2009 00:30 |
|
My website has a particular PHP file "commonthings.php", outside of webroot, that almost every single script "includes" right at the start so that things like the database connection are set up before the real work of the script starts running. commonthings.php contains two types of content: 1) variables like the database name, database account name and password, email address and account password, switches that allow me to enable or disable login, the site's address (for echoing into scripts); stuff that will need to be clear and uncluttered for when I want to drop in and change things. 2) stuff that is set in stone and that I don't anticipate changing: the statement that sets up the database connection, a function for echoing the form that allows login. Since this file is called so very often, would there any kind of performance increase (or indeed decrease) if I were to eliminate whitespace completely throughout the block of content of type (2)? I mean, instead of having something that looks like php:<? $a = 1; $b = 4; $c = 9; $cxn = mysqli_connect($host,$user,$password,$database) or die ('Failed to connect to database'); function EchoLoginForm () { echo 'some stuff'; } ?> php:<? $a=1;$b=4;$c=9;$cxn=mysqli_connect($host,$user,$password,$database)or die('Failed to connect to database');function EchoLoginForm(){echo'some stuff';} ?>
|
# ? Jan 29, 2009 06:04 |
|
When the PHP file it is interpreted and then becomes OPCODEs that are excuted in the Zend Engine. The code should generate the same OPCODEs regardless of formatting.
|
# ? Jan 29, 2009 06:08 |
|
What I meant is, is it any faster at all at reading and interpreting the file? But I take it from your answer that no, it is not any faster. Thanks!
|
# ? Jan 29, 2009 06:15 |
|
Hammerite posted:What I meant is, is it any faster at all at reading and interpreting the file? But I take it from your answer that no, it is not any faster. Thanks! The biggest speed upgrades you can have when including a file many times is to not include it many times. Usually, you'll use statements like require_once("file.php");, which are pretty slow compared to imports in many other languages. A way to bypass this is to use a defined constant once a file is loaded and check it before including it again. This makes ugly code though, and in most cases is not worth it at all. I do not recommend it. I may not have everyone's approval on this, but optimizing the server-side code is rarely what you need to do to speedup your website. Overall, you'll get a bigger speedup for the client making sure everything is gzipped and using a cache than optimizing trivial things like file imports. As a general rule, downloading images, css and/or javascript files is longer than the processing needed server-side. Otherwise, the only big bottlenecks which really have a noticeable effect are operating on large amounts of data (image rendering, nested loop on large datasets, bad written templating engines without caching ever, etc) and SQL queries (look at indexes and whatnot, also use caches if possible).
|
# ? Jan 29, 2009 15:30 |
|
MononcQc posted:The biggest speed upgrades you can have when including a file many times is to not include it many times. Usually, you'll use statements like require_once("file.php");, which are pretty slow compared to imports in many other languages. A way to bypass this is to use a defined constant once a file is loaded and check it before including it again. This makes ugly code though, and in most cases is not worth it at all. I do not recommend it. What about passing by reference when necessary? I'm currently working on a project that was shooting back enough data to crash FirePHP, so I was thinking if I passed things around by reference (since most of it is references to constant data anyways) it might help improve performance.
|
# ? Jan 29, 2009 16:06 |
|
Ferg posted:What about passing by reference when necessary? I'm currently working on a project that was shooting back enough data to crash FirePHP, so I was thinking if I passed things around by reference (since most of it is references to constant data anyways) it might help improve performance. What kind of data do you have? why does it need to be moved around? It may be that the design of the solution is not right, rather than the moving data necessary.
|
# ? Jan 29, 2009 16:20 |
|
MononcQc posted:If you use large arrays or objects, passing by reference will certainly have its advantages if you can make sure you won't modify data when you shouldn't. It's going to give some savings on processing time and memory usage for sure. To some extent, this is more about design than optimization. I've got a lot of data being pulled, stored, and processed. I'm using a facade design pattern to hide the messy subsystem where all of this information is stored and clients will be pulling the information out as arrays. So when I say moved around all I'm saying is it goes from Source -> Facade -> Client. Not being able to refrain users from changing the data will suck, but it is what it is. The performance of FirePHP once I switched to references and spaced out calls was pretty amazing.
|
# ? Jan 29, 2009 16:34 |
|
So, this is perhaps a silly question, but I've never experienced it before: I've been developing a site on a server that is mostly PHP/MYSQL. To keep parts of the code clean, in the header of the page I do a require(dbconnect.php); - the file which does all the connecting to the database. It all worked fine... Now I've moved this project to a new server, and - as far as I can tell - the server is closing the connection immediately after the require(). Now, normally the connection is automatically closed at the "end of the script" and I always assumed this meant the end of the page, etc. but it seems, in this case to mean the first time it sees a ?> which might be the end of that piece, but hardly the end of the page. If this is correct, obviously coding the entire page in pure PHP (rather than partial PHP, partial HTML) would fix the problem, but I'm too deep to want to consider that, so any other option is better. edit: Figured out, and reminded myself of my love/hate with coding... don't leave old bits of code in files that reconnect to other databases! That won't work at all. A hamburger? fucked around with this message at 22:25 on Jan 29, 2009 |
# ? Jan 29, 2009 17:04 |
|
|
# ? May 16, 2024 14:04 |
|
While we're on the subject of speed, what is everybody's thoughts on a heavily OOP written site? The lack of structs in PHP makes it difficult to create lightweight objects, but with associative arrays you can easily work around this but not without eliminating intuitive design decisions. Is a lot of OOP going to inhibit performance a lot?
|
# ? Jan 29, 2009 18:43 |