Skip to content

u/AdorableZeppelin

In this archive from Oct 2010 to Feb 2015

4
posts
52
comments
0
media
123
score

There's no real reason to not use a framework. It will do most of the hard stuff for you (database abstraction, validation, session management, among many other things) that you would otherwise have to write in yourself dozens, if not hundreds, of times. Really, the only way a framework can hurt you is if you don't at least have an idea of how it's doing what it's doing. For example, if you're doing a $this->data->save($this->request->data) within a framework, you should know that what this is actually doing is taking the POST data and updating a row in the database.

Frameworks also get you in the OOP mindset with PHP, which is hard for some people to do. But, once you've figured it out, it will be like second nature and it will also make the jump to RoR or Django a little easier.

1 points

PHP is a good language. It's not the best, for sure, but there are countless well-known sites out there that are based on it. Your gripe with it may be because you've been doing it the hard way (that is, without a framework). Try picking up a framework (they all have their ups and downs, and everyone has their opinion on the 'best' one, so just do some research to find one that sounds good to you) and see how you like it. If you're still not feeling it, try out RoR or python/django. Then if you're really desperate you can try out .net.

Do know that there are a plethora of PHP jobs out there right now, though, so it's a great thing to have in your toolbox. It may be an entirely different story in a few years however.

1 points

You can set the time() function to a variable, then return it. Or you can return an entire div with all the information you want in it, then change the .append(comment) to .append(data).

So something like this in add_comment.php:
echo true; becomes
echo "<div class='each_comment'><small><em>$time_variable</em> </small><br />$comment</div>";

Then in index.php change .append(comment) to .append(data).

1 points

It's not calling the function because it's not 'actually' there. Include the users file (or whatever you've called it) in the comments file and change get_comments back to post_comment and you should be good to go.

1 points

Wait, so comments.php is just this code?

<?php

if ((isset($_GET['action'])) && ($_GET['action'] == "post")) {
    /* problem area */
    post_comments($_POST['comment']); 	
}

echo link_comment(get_comments());

?>

Where is the code you posted above this in the OP?

1 points

Can you post the relevant code from index.php? I'm not sure why it would have no problem echoing get_comments() but return an error with post_comments().

Also, change post_comments($_POST['comment_text']); to post_comments($_POST['comment']); since your post variable is called "comment" not "comment_text".

1 points

Try:

function post_comments($comment = null) {
    $comment = strip_tags($_POST('comment'));
    mysql_query("INSERT INTO comments     ('text','from','date_added') VALUES ('".$comment."','".$user_data   ['username']."','".time()."')");
    return true;
}

And about the GET + POST thing: I don't know that there is anything inherently wrong with it... I've just never seen it before. I figured I'd ask.

1 points

You should post the error.

Also, it seems you're sending GET and POST data in the same request... why?

EDIT: Just looking at you code, I'd say $comment = sanitize(strip_tags($comment)); is your problem. PHP doesn't have a "sanitize" function. You probably want just $comment = strip_tags($comment);

3 points

If you do go the University route, don't just waste the spare time you'll have. Work on your own projects or start freelancing in your free time. Too many people think that their degree entitles them to a job, when really all it does is open a few more "prestigious" doors for you (that is, lets you confidently apply for jobs that 'require' a bachelors degree). Having a portfolio of works along with your degree is what really matters. It shows potential employees that you put in the time at University and got your degree, but you also went above and beyond your degree and learned/worked on some 'real' stuff.

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.