Jump to content

scootstah

Staff Alumni
  • Posts

    3,858
  • Joined

  • Last visited

  • Days Won

    29

Posts posted by scootstah

  1. Why are you going in and out of PHP tags on every line? That's completely unnecessary and makes your code very hard to follow.

     

    I am hoping to figure out how to just remove the time portion in this code so that I can just present the date.

    You can do that with date(). If you just have a date/time string instead of a UNIX timestamp, you can use strtotime() or the DateTime library to create one first.

  2. You need to modify this part to add additional items to $_SESSION:

    if (mysql_num_rows($query) == 1) {
    $row = mysql_fetch_assoc($query);
    $_SESSION['username'] = $row['username'];
    $_SESSION['userID'] = $row['userID'];
    $_SESSION['password'] = $row['password'];
    $_SESSION['loggedin'] = true;

    return true;
    }
  3. CodeAcademy is typically well-regarded, although I've never used it personally.

     

    The key is to find resources that were created/updated within the last two years. If you find a blog article from 2007, it's not going to even be worth it to read. PHP has changed substantially over the years, as has web development as a whole.

  4. the json is "body" : "<p></p>";

    but I get echoed:

    "body" : "

     

    ";

     

    I think htmlspecialchars would change < to &lt, right?

    Yes. Then you'd be able to see the HTML on your screen.

     

    The other way is to write the response to a file, and then you'd have the raw response body.

     

    $results = file_get_contents($url);
    file_put_contents('response.txt', $results);

    Anyway the decode dont get confused of html tags, is it so?

    json_decode() does not care about HTML.

  5. Your framework repo needs some work. You need proper directory structure and namespacing on your classes. And you definitely need dependency injection, so that you don't have to do things like this:

     

    // Load model class
    protected function load_model($model) {
    	if(class_exists($model)) {
    		$this->models[$model] = new $model();
    	}		
    }

     

    Check out Pimple.

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