Jump to content

Jenk

Members
  • Posts

    778
  • Joined

  • Last visited

    Never

Posts posted by Jenk

  1. A Modular system doesn't 'need' anything :)

    Before you even begin - I highly suggest you read up on Design Patterns, Test Driven Design and that you start completely from scratch with any project. Get some Use Cases together, then schematics, interface designs, then class diagrams, etc. etc.

    When developing a system, very little time is actually spent coding. The bulk is designing.
  2. [quote author=mainewoods link=topic=107671.msg432412#msg432412 date=1158018398]
    -To make the system more secure, create an extra field to transmit to the second website from curl on the first website.  Make that field equal to the md5 hash of the sql statement you are going to transmit plus a 'secret word', like this:
    [code]<?php
        $security = md5($sqlstatement . 'php rules');
    ?>[/code]
    -on the other side you would make sure it passes security:
    [code]<?php
       if ($_POST['security'] != md5($_POST['sqlstatement'] . 'php rules')) {
            //doesn't pass security!
            exit; //or return a 'forbidden' header
        }
    ?>[/code]
    --using a security strategy like that you could even avoid sending the db username and password every call and just hard code them on the page on the second server.  It's probably a little more secure that way.
    [/quote]That is so vulnerable you may as well not even bother :)
  3. It's invalid syntax, so it needs fixing. I never said it was anything to do with the problem.

    Don't argue with me about it, argue with PHP ;) Turn E_NOTICE on and wait for the "Notice: Use of undefined constant username - assumed 'username'" error ;)
  4. echo your query to see that it is executing what you want it to.

    Then change your mysql_connect/query/select_db function calls to suffix 'or die(mysql_error());' on the end, like so:

    [code]<?php
    $result = mysql_query($query) or die(mysql_error());
    ?>[/code]
  5. [quote author=roopurt18 link=topic=107396.msg430949#msg430949 date=1157754396]
    Why not do something like:

    [code]
    $cols = Array('foo', 'bar', 'qwerty', 'wysiwyg');
    foreach($cols as $col){
      $tmp_col = addslashes($col);
      $sql = "SELECT * FROM table WHERE col='{$tmp_col}'";
      $q = mysql_query($sql);
      while($record = mysql_fetch_assoc($q)){
        $Results[$col] = ProcessRow($Results[$col], $record);
      }
    }
    [/code]
    From my experience, it's best to offload as much logic into SQL as possible.  If it provides the functionality, why not take advantage of it?
    [/quote]That is only true if you can execute as much of the query as possible within a single query.

    What Barand suggested is best, or perhaps:

    [code]<?php
    foreach ($data as $row) {
        if (!isset(${$row[2]})) ${$row[2]} = array();
        ${$row[2]}[] = $row;
    }
    ?>[/code]

    If() is to avoid errors.
×
×
  • 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.