Jump to content

Zane

Administrators
  • Posts

    4,362
  • Joined

  • Last visited

  • Days Won

    11

Posts posted by Zane

  1. Do not expect to get very much help from this community by attaching the PHP file. Our community is full of people who are weary to download a file from a complete stranger mainly for security breech reasons. That could easily be an executable whose extension is changed.

     

    Especially since you are absolutely new here.

     

    Post the code (within code tags please), and rephrase your question to be more clear

  2. <a href="/reports?next">Next</a>
    

    Unless you are using rewriteMod which I doubt, the above is an invalid URL

    If reports is a folder that contains an index.php file then the url is fine.

     

    All you have to do is check whether $_GET['next'] isset and then code around it. As far as changing a php variable on click, I dont believe that is possible. You would need to store the current month somewhere like in a $_SESSION variable... then use date("M", strotime("+1 month", $_SESSION['curMonth'])) to get the next month

  3. Retrieving the list of images should be one of the first things you do on this page since it is the feature of the page.

     

    The create_imagelist function should return $html... not echo it. Echo the return of the function..... dont echo inside the function.

     

    Try doing that and see what happens. I'm not positive that will indeed fix it... definitely a shot in the dark.

  4. There is no possible way of doing this with a fetch function. They were created explicitly to fetch the data from the dataset. I suppose you could get away with using a for loop and use mysql_num_rows for your threshold, but that is just ridiculous.

     

    My advice to you is to not stray from the fetch approach. Since you say you plan to select different datasets and use them outside the loop, it is probably the best idea to create an array for each of your datasets... for instance

     

    $query = "SELECT * FROM labor_rates";
    $go[] = mysql_query($query, $connection);
    
    $query = "SELECT * FROM ed_scores";
    $go[] = mysql_query($query, $connection);
    
    $query = "SELECT * FROM someTable";
    $go[] = mysql_query($query, $connection);
    
    $laborRates = array(); $ed_scores = array(); $someTable = array();
    
    while($row = mysql_fetch_array($go[0])) $laborRates[] = $row;
    while($row = mysql_fetch_array($go[1])) $ed_scores[] = $row;
    while($row = mysql_fetch_array($go[2])) $someTable[] = $row;
    
    echo "<b>$someTable[3]['name']</b>"; 

    Then you can use a foreach to loop through those .. or you can access your data directly like I demonstrated at the end.

  5. The fact that I am using a maxlength=8 option in my text box would most likely keep anything from ever happening malicious?

     

    HTML is not security nor is Javascript. They are both client side languages, meaning they can be changed by the user as they see fit. There are plugins out there to do just that, they are also used as debugging tools. An example is Firebug for Firefox. With it, anyone can see where the data is going, which PHP files are being included, they can change the HTML .. in a live fashion, they can execute Javascript commands live as well. Do not fret though and consider Firebug a threat. It is a very very useful tool in web development.

     

    Psycho answered your question the best... though he didn't exactly elaborate on it the best, it is indeed the answer to your question

     

    Sanitize, filter, escape, sanitize, etcetera. YOU are in complete control of what goes into your database, the same way as you are in complete control of what foods you ingest. The key here is knowledge.

     

    If you want to make sure nothing bad gets into your system, you will have to code on the side of your system... known as server-side....AKA PHP. Here are a few PHP functions to start you off..

     

    http://www.php.net/mysql_real_escape_string

    http://www.php.net/trim

    http://www.php.net/filter_var

     

    IMO, you're pretty safe with just mysql_real_escape_string. It is the only function that actually sanitizes the input for database entry. The other two are simply a way to reject unwanted things... like extra spaces ... or a malformed email address.

  6. They all look compatible to me.. Quite a beefy (albeit expensive) computer though.

     

    Wouldn't have hurted to post what each link goes to by the way. The most important link is the motherboard and you have it as the fourth one down.

     

     

    You may want to get a CD/DVD drive as well if you want to put an OS on it. ;) Although I'm sure you omitted it because, well, any kind would be compatible... just pointing it out though.

  7. There's no reason to store whether a restaurant is open or closed when you already have the open and close times in there. Using SQL you can tell whether it is open or close with the TIME() BETWEEN syntax combined with a CASE statement.

     

     

    SELECT `r_ofrom` , `r_oto` , `rid` ,
    CASE WHEN (TIME(NOW()) BETWEEN r_ofrom AND r_oto) THEN true
    ELSE false
    END as is_open
    FROM `restaurant`

    Then you will not have to do a double query... and the open/close value will be in something like $row['is_open']

     

    Using a ternary statement, in PHP, you can display text or images to show its status...

    echo $row[´r_name´] . " is " . $row['is_open'] ? "open" : "closed";

  8. Yes, but only if you destroy the session after 15 minutes of inactivity. Otherwise, users would be declared as online/active until they click logout or they close the browser, then you would have to make sure any cookies are destroyed as well therefore they could be assumed online/active for quite some time... depending on the expiry settings you have for your sessions and cookies.

     

    Storing it in the database would allow you to create a list of who is online/active. Without the use of a database, you would have to populate some external file on every page load with a list of who is online or offline..

  9. The function only acts as a convenience, there is no real benefit other than that.  In my opinon, if you use extract you will loose track of where your variables come from.  When I am coding I prefer to know whether it is a POST, SESSION, COOKIE, SERVER or GET variable whenever and wherever I use it.... unless I am creating a new variable with arithmetic purposes....

     

    Such as 

    $e = pow(($_POST['m'] * $_POST['c']), 2);

  10. If you posted all of your code we could help you more with suggestions.. I do not see in your code anywhere where you are defining colors or setting the background.  Are you using CSS classes or what?..

     

    Looking at your very first snippet of code I would immediately suggest the use of a switch, but then you mention that arrays have helped you out more now... I am sure there is an easier solution to what you are doing becaue you are doing nothing more than checking a value....after some apparent arithmetic that you have decided not to show (which is probably best seeing as you are only asking help with the structure and trimming the code down) but I am guessing you already have that part down pat.

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