Jump to content

scootstah

Staff Alumni
  • Posts

    3,858
  • Joined

  • Last visited

  • Days Won

    29

Everything posted by scootstah

  1. Can you confirm that str holds a value before passing it via AJAX?
  2. It's acceptable to use in this case, because otherwise if you fail to connect it's going to spit it out something like this for everyone to see: Warning: mysql_connect(): Access denied for user 'blah'@'localhost' (using password: YES) EDIT: By the way, why are you mixing jQuery with native Javascript? One of the most awesome things about jQuery is handling AJAX. jQuery.post unless you suppress the warnings/errors the correct way, which would be to set the php.ini directives "error_reporting" and "display_errors" to 0 and no, respectfully, for a live server. True, you shouldn't be displaying ANY warnings to the public on a live server. But there's no ill side effects from suppressing mysql_connect(). It ensures that if your code ever lands on an improperly configured server that the world isn't going to get a glimpse at your database credentials.
  3. It's acceptable to use in this case, because otherwise if you fail to connect it's going to spit it out something like this for everyone to see: Warning: mysql_connect(): Access denied for user 'blah'@'localhost' (using password: YES) EDIT: By the way, why are you mixing jQuery with native Javascript? One of the most awesome things about jQuery is handling AJAX. jQuery.post
  4. That isn't the default Apache behavior. This is usually done by routing everything through the index.php file. By doing this, pages are never technically "not found", since the index.php file exists. Therefore you can have the functionality you are looking for and force 404 headers when something is "not found".
  5. Whoops, made an error. Updated: <?php require "scripts/connect.php"; $query = mysql_query("SELECT * FROM p WHERE section='gtkphp'"); ?> <table id="barTop"> <tr id="sign"> <td id="blue"><b>Pages</b></td> </tr> <?php while($rows = mysql_fetch_assoc($query)): $id = $rows['id']; $title = $rows['title']; $body = $rows['body']; ?> <tr> <td> • <a href="viewp?view=<?php echo $id; ?>"><?php echo $title; ?></a><br> • <a href="viewp?view=<?php echo $id; ?>"><?php echo $title; ?></a><br> </td> </tr> <?php endwhile; mysql_close(); ?> </table>
  6. sprintf printf works the same way except it echo's it instead of returning it.
  7. And the answer is: a lot. So pick one you are proficient with, make sure it has libraries for this, and use it. Ask a vague question, get a vague answer. I'm not sure why you've got your knickers in a twist over it.
  8. That's not how it works. You need to put everything in the while loop that you want repeated. I imagine you want something like: <?php require "scripts/connect.php"; $query = mysql_query("SELECT * FROM p WHERE section='gtkphp'"); ?> <table id="barTop"> <tr id="sign"> <td id="blue"><b>Pages</b></td> </tr> <?php while($rows = mysql_fetch_assoc($query)): ?> $id = $rows['id']; $title = $rows['title']; $body = $rows['body']; <tr> <td> • <a href="viewp?view=<?php echo $id; ?>"><?php echo $title; ?></a><br> • <a href="viewp?view=<?php echo $id; ?>"><?php echo $title; ?></a><br> </td> </tr> <?php endwhile; mysql_close(); ?> </table>
  9. Fail You can do what he wants with a ton of languages. Without asking a more specific question, that's all he's going to get. next time I want to make a synthesizer in CSS, ill come to you It's funny the attitude you are giving me considering your signature,
  10. You don't necessarily need to output an error. Just design in such a way that unhandled errors aren't going to happen. For example don't rely on a database query happening and then have a bunch of undefined variable errors. If you rely on something that should always happen, then you could always do a 500 - Internal Server Error if it doesn't happen. It will likely only be a very temporary thing, like a hiccup in the database or something. You can turn on error logging in the background to give you more detailed information without the public knowing. After all, when your server takes a shit the last thing you want to do is tell everybody the problem.
  11. Fail You can do what he wants with a ton of languages. Without asking a more specific question, that's all he's going to get.
  12. It would likely be a ton more work to "retrofit" an existing CMS than it would be to just create your own.
  13. Okay, I misunderstood what users.php was for. So then yes, this would be for profile.php
  14. The one you are most proficient with.
  15. Even when it is released it will take a long time to be mainstream. 5.3 isn't even mainstream yet.
  16. How are you gathering what page to view on users.php? I don't see anything relating to a query string or anything. Try something like: if (isset($_GET['user'])) { $user = $_GET['user']; } else if (isset($_SESSION['user'])) { $user = $_SESSION['user']; } if (isset($user)) { $user = mysql_real_escape_string($user); $query = mysql_query("SELECT * FROM users WHERE id='" . $user . "'"); if (mysql_num_rows($query)) { // user found, do whatever } else { echo 'user not found'; } } else { echo 'you must be logged in to view your profile'; } To view the profile you'd go to users.php?name=James Smith If you don't supply a name, it tries to use the session. If it can't find the session either, it will say you need to login to view your profile. To "follow" other users, basically you're just going to fetch all posts by that user. So say your follow table is like: user_id | follow_user_id ------------------------- 1 | 2 1 | 3 1 | 4 So user 1 (lets say that's you) is following users 2, 3 and 4. Then you would just select the posts these users make in whatever fashion you wanted.
  17. Just leave the action blank and the form will go to the current page, you don't need to use PHP_SELF here.
  18. $_SERVER['PHP_SELF'] is vulnerable to XSS attacks and really shouldn't be trusted ever. Also, if you are accessing it with $PHP_SELF that tells me that you have register_globals on, which is bad bad bad. Turn it off.
  19. I would build a mini framework and use a modules system. Each thing (commenting, favoriting, rating...) would be its own module and completely independent of one-another. This way you can just drop in whatever module you want and you're good to go.
  20. You can't use onclick events with PHP. But you can use AJAX like that.
  21. By the way, if you want to do something similar to what I suggested, bear in mind that you can also pass variables to the header and footer...so you can dynamically slip in meta keywords and stuff. load_template('somepage.php', array('keywords' => 'keyword, keyword2, keyword3')); in header.php: <meta name="keywords" content="<?php echo $keywords; ?>" />
  22. You make a for loop but you aren't accessing each index, you just refer to the entire array again. Try something like this: $checks = $_POST['chkColor']; $where = ''; foreach($checks as $check) { $where .= 'id = "' . $check . '" OR '; } $where = rtrim($where, ' OR '); if (!empty($where)) { mysql_query("DELETE FROM crew_messages WHERE " . $where); }
  23. You can use that function in OOP. Just because you use OOP doesn't mean you can't use procedural functions as well. If you want the template system to be more advanced feel free to implement an OOP solution. In the end your markup is sent to the browser one way or another, and this is what Google will see. It doesn't matter if you write the entire layout on every page or section it off like this. The advantage to doing it the way I suggested is that you don't duplicate code. If you have your entire layout on every single page, and then decide you want to change one little thing in the layout you have to edit every page. If you use my suggestion, you simply edit the header.php and you're done.
×
×
  • 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.