Jump to content

scootstah

Staff Alumni
  • Posts

    3,858
  • Joined

  • Last visited

  • Days Won

    29

Everything posted by scootstah

  1. Yup, I don't understand why the break should be indented. It is basically the same as brackets... everything inside the case is of course indented but the break should not be.
  2. For me, I started off with the braces on the same line and evolved to the second because of standards with projects I worked with. However I do find it cleaner now. Same here. Although I still don't like my conditional brackets being on the next line. I don't know why, it just doesn't look good to me.
  3. That just sounds like a design flaw. When you reset your password you should have to enter the email on the account you have forgotten the password to. If the email doesn't exist, it should tell you as such.
  4. Okay, so if you have these two files: shop.php interface Shop{ public function getshop(); public function displayshop(); public function purchase($name); public function sell($name); public function rent($name); } foodshop.php class Foodshop implements Shop{ // codes here } And then your autoloader: function __autoload($class) { require strtolower($class) . '.php'; } And then instantiate: $foodshop = new Foodshop; Since both "Foodshop" and "Shop" are not yet loaded, both classes are passed to __autoload() and then loaded.
  5. mysql_real_escape_string or better yet, prepared statements offered by MySQLi or PDO.
  6. I'm pretty sure if you try to extend or implement a class that hasn't yet been called it will go through the autoloader.
  7. You're using a greedy quantifier. Change (.*) to (.*?).
  8. Sorry, but we can't help you if you don't post code. 130-150 queries for a simple search is pretty much insane. I'm 99% sure you could do whatever you're doing in a single query.
  9. the project I was working on required the user to be logged in, perhaps that was why I had to use cURL. Thanks for the correction. You could probably do that with file_get_contents as well, but cURL is probably easier for that.
  10. To use autoloaders, it is best to have strict naming standards. For example, all files lowercase and all classes start with uppercase. You'll also have to use only one class per file, because with an autoloader you load the class based on the file name.
  11. When you login a user you need to store the user ID in a session. In some pseudo-code; if (login == successful) { $_SESSION['user_id'] = $row['user_id']; } At the very top of each script, put session_start() so that you can access the session. In your query, do something like SELECT m.memberid, p.memberid, p.uploaded, p.downloaded, p.total_posts, p.invites_left, p.points FROM tsue_members m, tsue_member_profile p WHERE p.memberid=m.memberid AND p.memberid='$_SESSION['user_id']';
  12. Wahoo... good eyes... I just grabbed the code from firebug, but firebug must have rearranged it. It's working now. Thanks. Yeah, Firebug reformats stuff to make sure it's up to standards. If you want to do something like this you'll need to view the raw source.
  13. I forgot to stick the header redirect back in. Does that help? if (!empty($_POST)) { $insert_query = "INSERT INTO Car (Make,Model,Price) VALUES (?,?,?)"; $Make = $_POST['Make']; $Model = $_POST['Model']; $Price = $_POST['Price']; $params = array("$Make","$Model", "$Price" ); $result = sqlsrv_query($conn,$insert_query,$params); header('location: yourpage.php'); }
  14. That's not true. If you have allow_url_fopen set to true in the php.ini, you can view websites with it. @OP: The problem is because you switched the attributes of the <th> preg_match('#<tr><th scope="row" width="48%">Beta:</th><td class="yfnc_tabledata1">(.*)</td></tr>#', $content, $match);
  15. Generally you don't want to echo things from a function. As you can see, doing so limits what you can do with it. It looks like modifying that function might mess up things elsewhere. You could add another function to return the output using the hack above. It's not perfect but at least it's less code every time you want to do that. function return_more_fields($key, $before = '', $after = '', $content_filter = false) { ob_start(); if (more_fields($key, $before, $after, $content_filter) === false) { ob_end_clean(); return false; } return ob_get_clean(); }
  16. If you're only going to have 1 row you don't need a while loop. Just do $row = mysql_fetch_assoc($FetchCacheq).
  17. Oops, went too far with the conditional. if (!empty($_POST)) { $insert_query = "INSERT INTO Car (Make,Model,Price) VALUES (?,?,?)"; $Make = $_POST['Make']; $Model = $_POST['Model']; $Price = $_POST['Price']; $params = array("$Make","$Model", "$Price" ); $result = sqlsrv_query($conn,$insert_query,$params); }
  18. Another thing is that you are throwing around die(mysql_error())'s all over the place. That's bad enough in a development environment but is a definite no-no in a production environment. All you are doing is aiding potential attackers. Just throw a 500 HTTP response and log the error. All your users need to know is that something didn't work.
  19. You only need to go back one directory. include_once('../database_connection.php');
  20. I think the problem might be that more_fields() is echo'ing the status instead of returning it. So you'll probably want to modify it to be able to return a value. If you find the function definition I can help with that. Alternatively, you can use output buffering as a sort-of hack, but I'd recommend the other option. ob_start(); more_fields('status'); $status = ob_get_clean(); switch($status) { case 'Red' : echo "Your account is currently undergoing judgement"; break; case 'Green' : echo "Your account is currently Live"; break; case 'Yellow' : echo "Your account is currently undergoing site visits"; break; case 'Blue' : echo "Your account is currently undergoing insolvency/liquidation"; break; }
  21. Haha, that made me laugh. You might want to make that a little more friendly in a production environment. I'm a little concerned about where $cID is coming from, it is not defined in the code you posted. So that means it is either defined before the code you posted or you have register_globals on. Also, you are not really handling any problems that may come from uploading a file. Neither are you ensuring the file is actually an image, and you are forcing its file extension to a jpeg.
  22. Are you talking about when you refresh the page and you are asked to send the POST data again by your browser? To get around that you'll need to header redirect to the same page. if (!empty($_POST)) { $insert_query = "INSERT INTO Car (Make,Model,Price) VALUES (?,?,?)"; $Make = $_POST['Make']; $Model = $_POST['Model']; $Price = $_POST['Price']; $params = array("$Make","$Model", "$Price" ); $result = sqlsrv_query($conn,$insert_query,$params); $describeQuery="select Make,Model,Price from Cars"; $results = sqlsrv_query($conn, $describeQuery); header('location: yourpage.php'); } However this is going to give you a header's already sent error because you have output above it. You'll either need to move your form below this code or use output buffering.
  23. My knowledge on SQL Server syntax is limited but I think it may be an issue with the alias. Try this: $describeQuery = "SELECT ID, Name, (SELECT COUNT(*) FROM MonthlySales WHERE ProductCode=Products.ID AND Year = 1990) AS num_sales FROM Products";
  24. Okay. What specifically does it output on the second line?
  25. You are not checking for a POST request, so you are just going to be inserting empty rows every time you load the page. The $_POST superglobal is only going to be populated when you send a POST request. So do something like; if (!empty($_POST)) { $insert_query = "INSERT INTO Car (Make,Model,Price) VALUES (?,?,?)"; $Make = $_POST['Make']; $Model = $_POST['Model']; $Price = $_POST['Price']; $params = array("$Make","$Model", "$Price" ); $result = sqlsrv_query($conn,$insert_query,$params); $describeQuery="select Make,Model,Price from Cars"; $results = sqlsrv_query($conn, $describeQuery); }
×
×
  • 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.