Jump to content

davidannis

Members
  • Posts

    627
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by davidannis

  1. But that is a terrible idea as it completely breaks the encapsulation provided by a function in the first place.

    I am not advocating that you use superglobals as a way to pass data in and out of functions, just pointing out that they break the rule of encapsulation.

     

    When I have a lot of values to pass out of a function my approach is often to build an array and use the array as a return value. What do you think of that approach?

  2. I would start by echoing $verify_Event_sql and running it against the database perhaps in phpMyAdmin to see what results you get. Then do the same with $get_Event_sql. Perhaps the second query is not producing results because it looks like the first query counts all events in the current month (Day is not considered) but

    WHERE DAY(Events.Event_Date)= Day(Now()) And MONTH(Events.Event_Date)=Month(Now()) And YEAR(Events.Event_Date)=YEAR(Now())
    

    looks at only events happening today.

  3. If you don't want a single person viewing a profile to be counted twice you can either store each view in a database (works with logged in users across browsers and machines) or store who's been looked at in a cookie (works without requiring a login but only within individual browsers so if the user looks at the office and home he is counted twice) or you can use both mechanisms if you have both logged in and non-logged in users.

  4. sometimes you get more. Hopefully I can deliver.

     

    Here's my pitch. If you represent a charitable organization, a 501c(3) recognized by the IRS, I will consider taking on projects or just helping with small changes, project planning and management, quality control, etc. for free. Please read my profile first to see what I have done and my skills. I won't take projects that are on tight deadlines (I do have a day job, a wife, and three children) or for organizations that advocate for things I don't believe in.

     

    I will have time beginning in mid-July. Contact me via private message.

     

    Not interested in programming for commercial ventures even if you pay me.

     

    David

  5. It should be possible. Use a loop. Pseudocode:

    $perm_conn=mysqli_connect(...combined_data);
    truncate combined data // make sure you start with an empty table
    $databases=Array('db0', 'db1);
    foreach ($databases as dbname){
    connection=mysqli_connect....$dbname);
    $select=//your select goes here
    $result=mysqli_query($select);
    while $row=mysqli_fetch_assoc($result){
    //clean up here and/or at end
    //write $row to perm_conn here;
    }
    close connection to $dbname and free $results here (don't want 100 open connections) 
    }
    //clean up, dedupe and send here
    

    Actually I like PravinS approach better, which you can also do in a loop.

  6. Looks like your host does not let you include files that are in certain directories (probably those above /home/a1632545/public_html) as a security precaution. That way if I can get a webpage on your server I can't do things like

    include '/etc/passwd' ; 

     If you move the files you want to include to a directory like /home/a1632545/public_html/includes it should fix the problem.

  7. You can make a program that serves the mp3 file only if the link has not already been used.

    Here's how I'd do it:

    When a link is created for a user create a random number and store it in a database along with the link id (autoincrement) and the name of the file to serve.

    Then output a link that looks like this http://mydomain.com/servefile.php?id=12345&key=734871637846

    when servefile.php runs it will read the database

    $id=mysqli_realescape_string($dbconn, $_GET['id']) ;
    $query="SELECT * FROM tablename WHERE id=$id";
    $result=mysqli_query($query);
    $row=mysqli_fetch_assoc($result);
    if ($row['key']==$_GET['key'] && $row['used']!=true ){
    //serve file here and mark link as used in database
    }else{
    // print an error message here;
    }
  8. The link should look like this (in context in viewmsg.php

                <b><p><a href="inbox.php">Inbox</a> | <a href="compose.php">Compose</a> |<a href="compose.php?replyto=<?php echo $sender?>">Reply to this message</a> | <a href="sent.php">Sentbox</a></b>
                <b><p><?php echo "$pm_count"." of 50 Total  |  "."$percent"."% full"; ?></p></b>
    

    Then in compose try something like:

           else
                {
                if ($_GET['replyto']!='') $receiver=$_GET['replyto'];
                //Here's the form for the input
                ?>
    
  9. Instead of calling the function each time:

     Door : <select name="door"  >
      <option>----</option> <option value="white" <?php if(get_value('door') == "white") { echo 'selected="selected"'; } ?> >white  </option>
      <option value="red" <?php if(get_value('door') == "red") { echo 'selected="selected"'; } ?> >red  </option>
     </select>
    

    you can call it once and use the return value multiple times which will be more efficient:

     Door : <select name="door"  >
    <?php $door_val=get_value('door')?>
      <option>----</option> <option value="white" <?php if($door_value == "white") { echo 'selected="selected"'; } ?> >white  </option>
      <option value="red" <?php if($door_value == "red") { echo 'selected="selected"'; } ?> >red  </option>
     </select>
    

    another strategy is to store the values of the colors in an array and then loop through it to create the select. That way, if you want to add 20 more colors you just add them once and don;t have a ton of code:

     Door : <select name="door"  >
    <?php $door_val=get_value('door');
    $door_colors=Array ('blue','green','red');
    ?>
      <option>----</option> 
    <?php
    foreach ($door_colors as $color){
    echo '<option value="'.$color.'" ';
    if ($color == $door_val) echo "selected=\"selected\"";
    echo ">$color </option>";
    }
    
×
×
  • 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.