Jump to content

RussellReal

Members
  • Posts

    1,773
  • Joined

  • Last visited

Posts posted by RussellReal

  1. its always a good idea to nest your conditionals.. if you think about it..

     

    if you had a neatly organized file cabinet you'd be able to find the paper you need faster.. than if you had all the papers in a pile and you have to use extra power to look through all of the papers..

     

    being neat is always looked @ by employers as well..

  2. you need

     

    ==

     

    ((value == value) && (value == value))

     

    is called if nesting, or thats what I call it..

     

    its used to GROUP conditionals together

     

    for example

     

    if (((value4 == value1) && (value1 == value3)) || (value2 == value4)) {

    }

     

    && = and

    || = or

  3. #1

          $SQL = "SELECT * FROM users WHERE username = '{$username}' ";

          $result = mysql_query($SQL) or die(mysql_error());

          $row = mysql_fetch_array($result);

          $pin = $row["pin"];

          $user = $row["username"];

          $level = $row["level"];

          $active = $row["active"];

    is not needed.. get all that data from the second query

     

    #2

    do the checks for if user is invalid or w\e BEFORE you do queries..

     

    #3

    on your localhost you probably have the database set up..

    on the server your database probably has errors.. like wrong types.. no table at all, misspelled table name.. etc etc

  4. also bro, not to contradict you.. but globals are very much unneeded.. there is a much better way with referencing the variable in the function call

    $omg = "lmao";
    whatever($omg);
    function whatever(&$geeze) {
      // $geeze will be a variable accessing $omg, instead of just handling teh VALUE of $omg.. meaning any change you do to $geeze in here, affects $omg..
    }

  5. hes trying to round to .5 intervals..

     

    ....

     

    thats why I wrote the function, everybody knows about round()

     

    EDIT::

     

    oo I see what sasa did :)

     

    *** RussellReal extracts foot from mouth ***

     

    *** And then inserts directly up the rectum of mjdamato ***

  6. ok for example:

     

    you have a table

     

    `menu_table`

     

    now.. the construct on this table is:

     

    int `id` auto_increment

    text `page`

    text `options`

     

    a fake entry of this table:

    `id` = 1
    `page` = index.php
    `options` = a:3:{i:0;a:2:{i:0;s:4:"HOME";i:1;s:9:"index.php";}i:1;a:2:{i:0;s:8:"SERVICES";i:1;s:12:"servives.php";}i:2;a:2:{i:0;s:9:"DOWNLOADS";i:1;s:13:"downloads.php";}}
    

     

    how we arrived at the options to look that way is rather simple to manage:

     

    <?php
    $arr = array();
    $arr[] = array("HOME","index.php");
    $arr[] = array("SERVICES","services.php");
    $arr[] = array("DOWNLOADS","downloads.php");
    $options = serialize($arr);
    ?>
    

    to undo the serialization is simple..

    <?php
    //do your mysql stuff here and read from the table for the current page
    $arr = unserialize($row['options']);
    $arr[] = array("PAGE TO ADD","PATH/TO/PAGE.php");
    $options = serialize($arr);
    

     

     

    I'm sure you could bridge something off of this to simplify the means of building menues for each of your pages :)

     

  7. hes trying to round to .5 intervals..

     

    not like

     

    1.5 to 2.0

     

    1.5 would be 1.5

     

    1.6 would be 1.5

     

    1.4 would be 1.5

     

    1.2 would be 1.0

     

    thats why I wrote the function, everybody knows about round()

     

    EDIT::

     

    oo I see what sasa did :)

  8. oh sorry bro it should be greater than instead of less than for the second if..

     

    <?php
    $page = $_GET['page'];
    $rpp = 4;
    $c = 0;
    $handle = opendir('comments/');
    
    if($handle) {
    
       while(false !== ($file = readdir($handle))) {
    
       if(preg_match("/\w+(.gif)/",$file)) {
           $c++;
           if ($c > (($page * $rpp) + $rpp)) break;
           if ($c >= ($page * $rpp)) {
                  echo "<div class='update_pics_frame'>";
                  echo "<div class='update_pics'>";
                  echo "<a href='comments/$file'><img src='comments/$file' width='200'border='0'></a>";
                  echo "</div>";
                  echo "</div>";
           }
    
    
       }
    ?>

  9. if you disabled auto increment your rows will require you to send an ID along with the INSERT, now, you could do without the ID row all together, however, that will lead to optimisation problems as you will have more than likely many results for 1 SELECT query, where as with an `id` you have unique rows throughout the table,,

     

    If you'd like you could add me to MSN RussellonMSN[at]hotmail.com

  10. <?php
    $page = $_GET['page'];
    $rpp = 4;
    $c = 0;
    $handle = opendir('comments/');
    
    if($handle) {
    
       while(false !== ($file = readdir($handle))) {
    
       if(preg_match("/\w+(.gif)/",$file)) {
           $c++;
           if ($c > (($page * $rpp) + $rpp)) break;
           if ($c <= ($page * $rpp)) {
                  echo "<div class='update_pics_frame'>";
                  echo "<div class='update_pics'>";
                  echo "<a href='comments/$file'><img src='comments/$file' width='200'border='0'></a>";
                  echo "</div>";
                  echo "</div>";
           }
    
    
       }
    

  11. make a menu table

     

    use serialize to group  values together.. in pairs OPTION -> VALUE

     

    $opt = serialize(array("option","value"));

     

    then store that into a db with all the other option serialisations seperated by \x01 or something unconventional

     

    then when you're going to place the next level in call that menu from the db and unserialize all the options and then place the options where they belong.. then you just need a menu table instead of a hundred text files for each menu..

     

    and its easier to work with in terms of coding the admin panel

  12. add me to MSN I actively help most of the people on my friends list with PHP and MySQL so you would fit in nicely..

     

    I also have done few tutor jobs for money but I prefer to help for free.

     

    My name is Russell and my MSN is RussellonMSN [AT] hotmail.com

     

    also: try <?php print_r($_POST); ?> to see if your values r being sent, and the construct of the print_r will tell you how you should reference the values

×
×
  • 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.