Jump to content

cpd

Members
  • Posts

    883
  • Joined

  • Last visited

  • Days Won

    5

Everything posted by cpd

  1. Without the contents of the style sheet no-body will be able to help you. I highly doubt the doctype is inserting some sort of white bar (could just be added padding or a margin) to the top of your page. Try debugging the code yourself by commenting out div tags...
  2. Running that on the final output every time isn't worth it in my opinion. You can worry for hours over something so petty or get on with developing your system.
  3. You'll probably find they don't merely md5 something but rather go through a series of steps and md5 it at the end. Take a step back and look at the bigger picture before drawing a conclusion.
  4. That's a very open ended question. Instead of asking how do to something provide is with what you have and then we can assist in developing your code further.
  5. Echo the contents of $_GET['x'] to ensure its the expected value.
  6. Killing the script because of invalid data isn't a good idea either. You should be able to handle this and send and give an error message allowing the user to adjust the details.
  7. Where you carry out validation is dependent on your system. If your just writing procedural scripts you can place it at the top of the script but if your using an MVC approach you can place it in your Model.
  8. You don't have to, I just did; its just an alias. Now in your query you can write `st` as opposed to the full `student`, makes life easier.
  9. That query doesn't make sense. If you use a WHERE clause you must give conditions of which you've given none: "SELECT * FROM `admin` WHERE `adminfullname` = 'Something' AND `department` = 'Something'" As for the other query you can do something like: "SELECT * FROM `student` `st` LEFT JOIN `surat` `su` ON `su`.`student_id` = `st`.`student_id`"
  10. You'd have to get the contents of the raw page and search for the $poweredby variable. In all honesty its not worth it and in most cases the overhead involved with encrypting/decrypting everything isn't worth it either. As a php dev its something you learn to live with and is usually addressed through a User License Agreement.
  11. As far as I can tell there is no relationship between admin and the other two tables (hence Christian's question) and as such you would need a minimum of two queries to retrieve data from both.
  12. As long as its a valid dll file you should be able to import it fine. The fact its made in Delphi is irrelevant as you've compiled for Windows. Assuming the dll is registered on the PC/Server you're using you should be able to import it. Silly question: Are you running Windows or Linux?
  13. I would never put the authentication logic into a controller. Instead it should be placed in an abstraction layer that implements an Authentication interface. The AuthController can then execute an "authenticate()" method defined by the Authentication interface allowing any authentication object (OAuth, database authentication etc) that implements the Authentication interface to be passed to the "AuthController"; this is polymorphism. The AuthController doesn't care for how authentication is carried out, it only expects a true or false response so it can then set the relevant session data. That said, I don't think the OP states an MVC architecture so this is all going a little off piece.
  14. Still not good enough I'm afraid. We need the foreign and primary keys of your database so we can help you with the query.
  15. Pencil and paper my friend. You firstly want a method "hasThumbnails()". Then another two methods "scrapeThumbnails()" and "scrapeMainImage()". That's about all we can help you with because the body of those methods is dependent on the content of the pages which you haven't supplied. Your code would be along the lines of: <?php foreach($pages as $page) { if(hasThumbnails($page)) { $image = scrapeThumbnails($page); } else { $image = scrapeMainImage($page); } } ?>
  16. I agree with TOA. The actual validation of login credentials probably shouldn't be in the User class but instead in some sort of Authentication class. You can still have a login method that sets the necessary session data but doesn't actually carry out any queries.
  17. You haven't 100% clarified what your trying to do but I'm guessing you want to begin searching the minute they select 1 item and to then restart the search when they select another item?
  18. Sorry for my earlier suggestion I wasn't thinking right. Unless you explain what your expected result set is no-one can really help you write your query.
  19. You shouldn't extend to the database class as it effectively means your saying "A User is a Database" which is complete wish-wash. Extending "because I want to use what's available in the super object" isn't a reason to create a inheritance hierarchy. A User may USE a database object but it doesn't represent a database itself nor should it contain the logic to directly interact with the database. Passing the database object via the method isn't wrong or right, its merely another method. I feel the database object should be passed to the User object for use. E.g. <?php class Database { // Code emitted } class User { private $database = null; public function __construct(Database $database) { $this->setDatabase($database); } private function _setDatabase(Database $database) { // Carry out validation on the $database object $this->database = $database; return true/false; } public function login() { $this->database->query("Some query"); // Some logic return true/false; } } $database = new Database(); $user = new User($database); ?>
  20. Do a var_dump on the $results variable and you'll likely see you have dupes meaning you need to review your SQL as its doubling up the data.
  21. In the given scenario I would argue the database object should be passed to the user object upon instantiation. This will prevent you having to create multiple instances of the same database class. Alternatively you can use the Singleton pattern to ensure a single instance of the database class is created. My previous comments speculate slightly and its worth noting every system will have some dependencies. You can limit the dependency on the database object by creating a factory that instantiates database dependent classes and passes the database object to them. This then allows the classes that need a database to be instantiated without ever knowing where the database object actually is.
  22. Not really sure what string your referring to as you have 3 potential strings. You can define a "toString()" method giving a generic string to display the state of your object; this is similar to the toString method in Java and it works really well.
  23. Not really sure how you plan on programming the profile page(s) but both methods I'm thinking of are horrible. Your link should only be website.com/profile.php, or similar. Assuming you don't need to be logged in to view a profile you can append what's known as a query string to your URL as follows: website.com/profile.php?user=MyUsername and query your database for the users details. A brief explanation on query strings: ? denotes the beginning of the query string. user is the variable name and MyUsername is the value. the value can be retrieved in your code using the special $_GET super global i.e. $_GET['user']; You can have multiple variables using this syntax: website.com/profile.php?user=MyUser&variable2=someValue&anotherVariable=somethingElse By using the $_GET variable you can query your database for whoever you want thereby creating a single php script. This is the basis of php: its a language used to create dynamic pages amongst other things.
  24. There is an issue when you have namespaces because your creating a dependency. In fact, you've got a dependency here where the class creating the Database object is dependent on it being in the same namespace.
×
×
  • 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.