Jump to content

Saragon

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Everything posted by Saragon

  1. I'm building a mySQL database for a property manager's website -- a much larger database than my previous projects. (Not Oracle-sized by any means, but still new to me.) I never played around with VIEWs much before now, but I'm wondering whether or not they might speed things up. To browse through the properties, I'm going to use the standard ten-at-a-time list, with certain pieces of information (rent, street, thumbnail image, etc.) displayed for each one. There's also a large table for amenities that are mostly boolean values (fireplace?, pets allowed?, cable?, and so forth). Each of these pages will see a lot of use. Which is the better practice: To pull the data directly from the base tables via PHP and have the appropriate function control what's shown? Or have a SQL VIEW already in place that contains the data, and have my code put the entire row into an array or something similar?
  2. [!--quoteo(post=381981:date=Jun 9 2006, 02:04 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Jun 9 2006, 02:04 PM) [snapback]381981[/snapback][/div][div class=\'quotemain\'][!--quotec--] Don't use curly brackts, but round brackets or parentheses: [code]function stripFormSlashes($arr)[/code] [/quote] I also apparently need to get my eyes checked. Or I need to get a new monitor -- I can barely distinguish between the two in PHP Designer `06. Hmm. Thanks, Poirot.
  3. The following is lifted straight out of Christian Wenz's "PHP Phrasebook: Essential Code and Commands". It's a handy function designed to clean extra "magic quotes" slashes out of form data. Unfortunately, it's throwing a parse error that seems completely unreasonable. The error is as follows: [b]Parse error:[/b] parse error, unexpected '{', expecting '(' in [server root]/[subdirectories]/stripFormSlashes.inc.php on line 2 [code]1 <?php 2     function stripFormSlashes{$arr} 3     { 4       if (!is_array($arr)) { 5         return stripslashes($arr); 6       } else { 7         return array_map('stripFormSlashes', $arr); 8       } 9     } 10     11     if(get_magic_quotes_gpc()) { 12       $_GET  = stripFormSlashes($_GET); 13       $_POST = stripFormSlashes($_POST); 14     } 15 ?>[/code] I'm calling this with the following: [code]<?php require_once 'stripFormSlashes.inc.php'; ?>[/code] Now, as near as I can tell, line 2 is just fine. So is the rest of the code, for that matter -- I've no unclosed parentheses anywhere. Nonetheless, it simply will not parse. What obvious thing have I overlooked here?
  4. [!--quoteo(post=371052:date=May 3 2006, 04:32 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ May 3 2006, 04:32 PM) [snapback]371052[/snapback][/div][div class=\'quotemain\'][!--quotec--] Where is the 'scripts' directory in relation to your script? kEN[/quote] The home directory, where the 'index.php' file and the variant CSS files are stored, has two sub-directories: 'scripts' and 'images'. The latter contains only image files; the former contains the 'browserdetection.php' script in question. In other words, here's the relevant file list: .\index.php .\rgstyle_ie.css .\rgstyle_moz.css .\scripts\browserdetect.php
  5. [!--quoteo(post=371031:date=May 3 2006, 03:30 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ May 3 2006, 03:30 PM) [snapback]371031[/snapback][/div][div class=\'quotemain\'][!--quotec--] Did you download this package? If so where did you put it? Ken [/quote] I did (there's a link in my first post to it, I believe) and it's in the 'scripts' directory. It's a single file -- really just three functions.
  6. Sadly, neither suggestion has worked. [code] <?php include($_SERVER['DOCUMENT_ROOT'] . "/demos/scripts/browserdetect.php"); $browsername = browser_detection(browser); $cssincluder = '<link rel="Stylesheet" href="rgstyle_' . $browsername . '">'; print htmlentities($cssincluder); ?> [/code] I've tried it with and without the $_SERVER prefix -- nothing doing. Is the "include" function even the right one to use? Is there some other way to link in external scripts that contain functions?
  7. I have a very basic question. I'm trying to use the following code to pick a browser-specific stylesheet (Mozilla and IE's minor differences tend to be magnified by this particular design.) I'm teaching myself PHP for this purpose, and am getting the following error messages: [i]Warning: main(/nfs/cust/0/93/06/660390/web/demos/scripts/browserdetect.php): failed to open stream: No such file or directory in /nfs/cust/0/93/06/660390/web/demos/rgproperties/index.php on line 7 Warning: main(): Failed opening '/nfs/cust/0/93/06/660390/web/demos/scripts/browserdetect.php' for inclusion (include_path='.:/usr/local/php/include') in /nfs/cust/0/93/06/660390/web/demos/rgproperties/index.php on line 7 Fatal error: Call to undefined function: browser_detection() in /nfs/cust/0/93/06/660390/web/demos/rgproperties/index.php on line 8 [/i] I know enough to know that this basically means [i]browserdetect.php[/i] isn't being found, and I suspect that's because I'm not properly linking the file into my main [i]index.php[/i] file. Is there a better way? [code] <?php     include($_SERVER['DOCUMENT_ROOT'] . "/demos/scripts/browserdetect.php");     $browsername = browser_detection(browser);     print '>link rel="Stylesheet" href="rgstyle_' . $browsername . '"<'; ?> [/code] (The > and < in the last line are inverted solely because I can't make the LINK tag appear in the CODE block otherwise. I'm not [i]that[/i] bad. ;) ) Oh, and the "browserdetect.php" script is courtesy of Harald Hope, and can be found at [a href=\"http://techpatterns.com/downloads/php_browser_detection.php\" target=\"_blank\"]http://techpatterns.com/downloads/php_browser_detection.php[/a].
  8. [b]redbullmarky[/b] -- thanks very much! I understand XML a bit better than SQL, so that'll probably be the way to go (and it will be much more portable and easier to tie into an RSS feed, too, I think.) [b]cphp[/b]'s [a href=\"http://www.phpfreaks.com/tutorials/135/0.php\" target=\"_blank\"]Planning PHP Projects[/a] tutorial has also helped me get organized, so he deserves some credit too. My one concern about using XML to store blog data is the slow increase in read time: As I append blocks of data to the XML file, the most recent entry (and thus the entry called first for display) is the last major element in the file. The second entry will be the second-to-last, and so on and so forth. Thus any script that pulls data from the XML file by timestamp will have to go all the way to the end of the file to get it -- very slow. It's only text, so it's not a [i]huge[/i] problem, but is there a clever way to either (a) insert entries into the 'top' of the XML file, so that the most recent items are accessed first by a simple search? or (b) 'jump' quickly to an element with a particular value or attribute value? (If there isn't, the easiest thing to do be to create individual XML files for a particular period of time, say a year, to keep search times per file low.)
  9. This might belong in the "Tutorial Help" section, but I'm new enough to PHP that I definitely qualify as a newbie, so here goes. I'm currently trying to do several things at once: Build a webpage (something I'm not too bad at, at least from a design perspective) and learn PHP (something I've just started at, and am not at all good with yet.) My design for the site includes a newspost/blog on the front page, but every open-source PHP blog I've come across (even the ones that claim to be simple) have too much excess on them. All I'm really looking for is a way to organize bits of news by date of creation and post a certain number to the front page, with an archive page for the rest. Since it's for my personal site, I can add complexity to it as I see fit, and so this strikes me as a great opportunity to learn some 'real world' PHP at a level slightly above most beginner tutorials. Unfortunately, I can't find any tutorials or guides on how to build a very basic blog from the ground up, and I'm not good enough at PHP yet to disassemble other blogging code and see how it's done. What I need, therefore, is a good 'DIY' blog tutorial that others have either found or made (I couldn't find one in the tutorial section here, sadly.) Barring that, I'd be happy with a suggestion or two on how I should start thinking the design through. I figure that best practice is to write entries, timestamps, etc. to a database, just as everything else is database-driven these days; beyond that, I really don't have any requirements. Any advice and help is [i]much[/i] appreciated. Thanks a lot!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.