This tutorial really helped me but can someone explain something to me

Discussion in 'PHP' started by mnymkr, Nov 11, 2006.

  1. #1
    http://www.phpbuilder.com/columns/besserer20050729.php3?aid=952

    This made a lot of sense to me but one part

    He queries the database for
    $query = "SELECT `title` , `entry` , `date_entered` , `user` FROM blog ORDER 
    BY date_entered DESC";
    
    PHP:
    Then however I never seem him define 'entry' as a variable

    $date_entered = date ('F j g:i A', $row['date_entered']);
    //The time data is being formated for a proper display to the page
    		
    $user = $row['user'];
    $title = $row['title'];
    $entry = nl2br ($entry);
    PHP:
    What am I missing here?
     
    mnymkr, Nov 11, 2006 IP
  2. SoKickIt

    SoKickIt Active Member

    Messages:
    305
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    70
    #2
    It was probably a mistake..


    $entry = nl2br($row['entry']);
     
    SoKickIt, Nov 11, 2006 IP
  3. streety

    streety Peon

    Messages:
    321
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I think SoKickIt is correct here, probably just a mistake. Sadly you see it quite often. Writers tend to cover material they are comfortable with and comfort breeds complacency. They don't always test their code.

    There are actually a whole bunch of typos in the article, from what I've read so far just shy of 1 per paragraph.
     
    streety, Nov 11, 2006 IP
  4. thedark

    thedark Well-Known Member

    Messages:
    1,346
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    168
    Digital Goods:
    1
    #4
    writing examples is hard, you pay full atention to the purpose, but you forget simple things.
     
    thedark, Nov 11, 2006 IP
  5. mnymkr

    mnymkr Well-Known Member

    Messages:
    2,328
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    120
    #5
    well since everyone has been so helpful i was wondering if you can explain to me what

    /n is

    and when a variable = " "

    like the following

    function getHeader($own, $total, $Itemid){
      	$return = '';
    PHP:
     
    mnymkr, Nov 11, 2006 IP
  6. streety

    streety Peon

    Messages:
    321
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Debugging your code should not be something you forget. I've written articles in the past and had readers identify errors but they've all been errors which didn't affect the actual function of the code. I haven't run the script in the article here but I suspect the error would stop it from working.


    I think your /n should actually be \n, it's a newline character.
    Various reasons why your might set a variable to no value, if you have a loop you might want to ensure a variable is empty before writing to it. NOt the only reason but the first which springs to mind.
     
    streety, Nov 11, 2006 IP