Jump to content

Lamez

Members
  • Posts

    1,686
  • Joined

  • Last visited

    Never

Posts posted by Lamez

  1. I see a lot of people do something to distract them, like video games, I don't. I break out a marker and start writing my goal down on the white board, what I should do to get that goal, and things of that nature. If I don't get anywhere with that method, then I am probably too tired to program. So I go to bed. That is when algorithms start popping in my head. Sometimes I can't figure out why my code is not working, so I go to bed, like I said, I was probably too tired. Then when I wake up, look at the code I start to notice all sorts of syntax errors.

     

    At work I just grab a energy drink and program till we close, I love it.

  2. What the heck, why did it post that? Anywho here is the code I was working on:

    ------------

     

    Okay so you want to take the last five rows, and keep the order in DESC?

    <?php
    function clean($str){
    $str = @trim($str);
    if(get_magic_quotes_gpc()){
    	$str = stripslashes($str);
    }
    return mysql_real_escape_string($str);
    }
    $q = mysql_query("SELECT * FROM icu INNER JOIN bundle ON icu.id_incr = bundle.pt_id AND icu.id_incr = '" . clean($_GET['id']) . "'  order by bundle.bundle_date LIMIT 5"); //Never use a $_GET variable straight into a query. Anything that can be modified from the outside, needs to be clean.
    $n = mysql_num_rows($q);
    if($n > 0){
    $f = mysql_fetch_array($q);
    for($i=0; $i<=$n; $i++){
    	if($i >= ($n-5)){
    		echo $f['value'];
            }
    }
    }else{
    echo "No Data";
    }
    ?>
    

     

    I have not tested this, it should work, I think.

  3. I am a developer not a designer. Therefor I want to use a template engine in my new website (new as in revamped). Which one is the best? Do template engines come with different template I can download? Do I have to make my own? Are they hard to incorporate?  Is this the right board to post this in?

     

    -Thanks! :)

  4. How would I get the current folder of which my website is in? Pretty much, how would I edit $_SERVER['REQUEST_URI'] to show the last folder?

     

    Exmaple

     

    if REQUEST_URI = /folder1/another_folder/page.php

     

    how would I get /folder1 ?

     

     

  5. As for looking at the string for numbers: I don't want people registering with names like: Johnny12 or anything like that, so I want to return a error saying you may not have numbers. That is all.

  6. First Question:

    How would I force a function when the user closes the browser? Would that be javascript? When the user logs on to the website, it shows everyone they are online, but when they close the browser, they are still online. So I want to force my logOut(); function on them.

     

    Second Question:

    Is there a function that allows me to examine a string, and look for a number and return a certain value, or do I have to write one myself? If so, how would I go about doing that?

     

    -Thanks for all the help!

     

  7. I will move the error_reporting line. Yes the wide-variables.php is being included, because I got errors before, and fixed them immediately. I don't think the includes are "out of control", and I will keep them the same. All the files seem to be included, for some very odd reason, I cannot connect to the database from that folder. I can from the members folder. I still have no clue why.

  8. <?php
    function getBrowser() {
    $u_agent = $_SERVER['HTTP_USER_AGENT'];
    $ub = 'other';
    if(preg_match('/MSIE/i',$u_agent)){
       		$ub = 'ie';
    	}
    	elseif(preg_match('/Firefox/i',$u_agent)){
       		$ub = 'firefox';
    	}
    	elseif(preg_match('/Mozilla/i',$u_agent)){
       		$ub = 'firefox';
    	}
    	elseif(preg_match('/Safari/i',$u_agent)){
       		$ub = 'safari';
    	}
    	elseif(preg_match('/Chrome/i',$u_agent)){
       		$ub = 'chrome';
    	}
    	elseif(preg_match('/Opera/i',$u_agent)){
       		$ub = 'opera';
    	}
    return $ub;
    }
    $browser = getBrowser();
    if($browser == 'ie'){
    $url = 'http://www.google.com';
    }elseif($browser == 'firefox'){
    $url = 'http://www.google.com';
    }elseif($browser == 'safari'){
    $url = 'http://www.yahoo.com';
    }elseif($browser == 'chrome'){
    $url = 'http://www.ask.com';
    }elseif($browser == 'opera'){
    $url = 'http://www.ask.com';
    }
    header("Location: ".$url);
    ?>

     

    I would about it that way, just in case you want to change the url's later.

  9. As requested:

    db-config.php

    <?php
    include("wide-variables.php");
    define('ADMIN', "admin@webby.com", true);
    define('MOD', "mod@webby.com", true);
    
    $DB_CONN = mysql_connect($_DB_SERVER, $_DB_USER, $_DB_PASS) or die('<font color=red><b>Site Returned Error:</b></font> '.mysql_error());
    mysql_select_db($_DB_NAME, $DB_CONN) or die('<font color=red><b>Site Returned Error:</b></font> '.mysql_error());
    ?>
    

     

    and wide-variables.php

    <?php
    //Start Session
    session_start();
    error_reporting(E_ALL);
    //Page Variables
    $_SESSION['currentPage'] = currentPage();
    
    //Datbase Config
    $_DB_USER = "x";
    $_DB_PASS = "x";
    $_DB_SERVER = "x";
    $_DB_NAME = "x";
    /*
    $_DB_USER = "x";
    $_DB_PASS = "x";
    $_DB_SERVER = "x";
    $_DB_NAME = "x";
    */
    //Table Variables:
    define('TBL_PEOPLE', "people", true);
    
    //Path Variables:
    $_pear = "";
    $_core = "core/";
    $_includes = "core/includes/";
    $_style = "core/style/";
    $_pages = "/pages/";
    
    //Redirect Variables:
    $_main_error = $path."index.php";
    $_not_member_area = $path."index.php";
    
    //If's
    if(isset($Login) && $Login){
    if(!LoggedIn()){
    	header("Location: ".$_not_member_area);
    }	
    }
    if(isset($AdminOnly) && $AdminOnly){
    if(!LoggedIn()){
    	header("Location: ".$_not_member_area);
    }else if(!isAdmin()){
    		header("Location: ".$_not_member_area);
    }
    }
    if(isset($ModOnly) && $ModOnly){
    if(!LoggedIn()){
    	header("Location: ".$_not_member_area);
    }else if(!isAdmin() || isMod()){
    	header("Location: ".$_not_member_area);
    }
    }
    //CMD Stuff
    if(isset($_GET['cmd'])){
    $cmd = $_GET['cmd'];
    
    //Logout
    if($cmd == "logout"){
    	logOut();
    	header("Location: ".$_not_member_area);
    }
    }
    ?>
    

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