Jump to content

kc9ddi

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

kc9ddi's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I'm trying to write a relatively simple app in PHP - just a photo manager that lets you search by keywords.  I would like to write with the MVC paradigm to the greatest reasonable extent, but I'm having some trouble.  Basically, for simple CRUD functions, I have a file that's mostly HTML, with some tags like <? echo $template['pageTitle']; ?> to fill in dynamic content.  This file is the included by a model/controller type script.  This script is essentially a giant if-elseif-elseif... block.: [code] if($action == 'new') { } elseif($action == 'edit') { } elseif($action == 'delete') { } [/code] The problem I'm having is that the model/controller script is getting kind of ugly.  Any general suggestions for how to nicely organize an app like this?
  2. I'm working on a PHP script that stores some info in a mysql table.  I'm wondering about methods for encrypting data in certain columns, but allowing it to be decrypted by authorized users (eg, social security numbers).  MD5 and such are all one-way encryption, and I'm looking for something that can also be decrypted.  Is there a popular tool/method for this?
  3. I hate to ask this, but I'm having trouble working out the syntax for the SQL - would you mind giving me an example?
  4. I see - so, then, I'd need an additional join for each keyword I want to search?  eg, 4 keywords = 4 joins?
  5. I'm developing a simple photo album project.  I have one table that stores information about each photo (filename, format, size, etc.) and then a table of keywords.  The keywords table looks like: [code] id INT primary key, keyword VARCHAR, photo_id INT [/code] Each keyword gets its own row in the table, even if multiple photos have the same keyword.  Also, each photo can have multiple keywords that point to the same photo_id.  I think this is a pretty standard setup. What I'm trying to do is something like SELECT * FROM photos WHERE keyword='keyword1' AND keyword='keyword2' -- that is, find all photos that have BOTH keyword1 and keyword2.  I figured out a JOIN statement that does this for keyword1 OR keyword2, but am having trouble working one that does AND. Any ideas?
  6. Open the file passed as an argument, parse the PHP within the file, and return a string containing its parsed contents.  Right now this is what I have (altered from an example in the PHP Manual:) [code] function get_include_contents($filename) { extract($GLOBALS,EXTR_SKIP); if(is_file($filename)) { ob_start(); include($filename); $contents = ob_get_contents(); ob_end_clean(); return $contents; } return false; } [/code] I do think its pretty ugly (particularly the extract($GLOBALS) part), but its the only thing I could come up with.
  7. Hi - I'm trying to implement a simple templating system for my site.  I'm trying to do something resembling the MVC paradigm.  So, I have a model/controller php script, and then a view php script.  The model/controller does all the logic, and the view has mostly html with a few <?= $template['variable']; ?> to put in dynamic content. I'm wondering if its possible to open the view php script, parse the php, but store the result into a variable, rather than outputing it directly to the browser. For example: view.php: [code] <p>Hello There</p> <p>Here is a message: <?= $template['message']; ?></p> [/code] controller.php [code] <? $template['message'] = "PHP Is cool."; $myVariable = open_and_parse('view.php'); ?> [/code] And then have $myVariable contain "<p>Hello There</p>\n<p>Here is a message: PHP is cool.</p>" Is this possible?
  8. That's a good idea, but I still don't know how to check the file in its temporary directory...
  9. A couple things you might try: 1) Escape the ? and & signs in the URL 2) Use the REQUEST_URI or other variable in $_SERVER and regexp-type functions to extract the correct portion of the URL
  10. Hi - I'm writing a simple program that lets users upload images to a server.  I only want them to be able to upload .gif, .png and .jpg.  I wrote a simple function that will check a file's MIME type, and return the appropriate extension.  I'm wondering how I could determine the path where the temporary files are stored, so I could do this check before I move the file to its permanent home.  Obviously, I could figure it out for one server and hard-code it in, but I'm hoping there's a way to determine it within the script.  Is this possible? Thanks
×
×
  • 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.