Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. Not sure this works but you can pass a domain to setcookie setcookie($name, $value, $expire, '/', 'www.domain2.com'); setcookie($name, $value, $expire);//current domain
  2. Well you have got a few options here: First option will probably won't work in your current design as you presumably want to limit 40 for a number of articles and don't want to create a table for each and every article: Limit 40 rows at database level: CREATE TABLE tableName ( #table defintion ) MAX_ROWS = 40; Second option is at application level: I am assuming you are using a MyISAM table if you don't then you may pass on this one unless you use SQL_CALC_FOUND_ROWS and SELECT FOUND_ROW() afterwards (altough this is slower then a count(*) on a MyISAM table) Why MyISAM? because MyISAM stores the number of rows by default therefor if you query SELECT count(*) FROM table it will return the number of rows rather quickly as it doesn't have to calculate it anymore. $query = 'SELECT count(*) found_rows FROM table'; $result = mysql_query($query, $db); list($found_rows) = mysql_fetch_array($result, MYSQL_NUM); if (40 < $found_rows) { //limit reached }
  3. Meaning the second is still a resource and is not yet resolved to any data structure like array or object.
  4. Your server has to be optimized for internet radio broadcasting. From that point on it just works like webcam broadcasting where the image is updated every x number of seconds.
  5. $row['print_status'] ? 0 : 1; returns 0 if print_status contains 1 and vice versa
  6. http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_substr Best practice here is not to limit to x number of characters as this may lead to some ambarrasing lines of text instead limit to some amount of words by using a combination of words and the total length of the string. If the total length exceeds the maximum length then x number of words less to meet the maximum length.
  7. $parts = explode("/", dirname(__FILE__)); $myFile = implode("/", $parts) . Why first explode it and then re-build it again? $myFile = dirname(__FILE__) . will give you the same as exploding first and then implode it again. Do var_dump($myFile); before $fh = fopen($myFile, 'w') or die("can't open file");
  8. function deleteSMS(&$sms, $delete_txt) { $sms = str_replace($delete_txt, '',$sms); } or: function deleteSMS($delete_txt) { global $sms; $sms = str_replace($delete_txt, '',$sms); }
  9. change $users->id to $users['id'] Second do a var_dump($users); before foreach ($users as $user)
  10. Well, that's kind of obvious considering the title of this thread. But, I appreciate your efforts. However I need the pages to be in order and for the proceeding one not to replace the previous when you revisit an old page. You mean like a history? That is what my current code is designed for it will log each and every page visit (even refreshes altough you can exclude these if you get the last page visited and compare that to the current page). Use $array[$length - 2] to get the previous url visited as $array[$length - 1] will be the current page $array[0] is the page of entry.
  11. The first error points out that $user is not an object. Try var_dump($user); The second error is because of: return = self::find_by_sql("SELECT * FROM photo_gallery_users"); Which should be: return self::find_by_sql("SELECT * FROM photo_gallery_users");
  12. There are no % wildcards so that query wouldn't match things like you stated.. That was my first idea to. I consulted the manual but they only talk about the different possible pattern's they never actually say what LIKE does when no pattern's are provided.
  13. Yeah I know, but it was an example. Nevertheless wether he types chinese, french or some other language the signals are still hexadecimal and thus falls within some range just like A-Z does or a-z does. IMO it's worth a go. And if it doesn't work which is most likely as ord() converts to ASCII then I wonder which other ways their are to retrieve the hexadecimal value of a japanese character? Would converting to the appropriate encoding help?
  14. We are not debugging tools. Add this code to the top of your script: error_reporting(E_ALL); ini_set('display_errors', 1);
  15. Don't just return "Invalid user" avoid typo's and use constants. define('PROFILE_ERR_INVALID_USER', 'invalid'); function profile($uid, $link = FALSE) { $sql1 = "SELECT * FROM `users` WHERE `id`='".$uid."'"; $res1 = mysql_query($sql1) or die(mysql_error()); if(mysql_num_rows($res1) == 0){ return PROFILE_ERR_INVALID_USER; } else { $row1 = mysql_fetch_assoc($res1); if (!$link) { return $row1['username']; } else { return $row1['username']; } } } Afterwards use: $response = profile(..); if (PROFILE_ERR_INVALID_USER !== $response) {
  16. Like skunkbad said your buddy needs to use cURL. What skunkbad however didn't said was that he has to post the user's ip address because if you would do: $_SERVER['REMOTE_ADDR']; You would end up logging your buddy's server ip address instead of his visitor's ip address.
  17. You don't need to start over just change WHERE `username` LIKE '$username' to WHERE `username` = '$username'
  18. What you see on screen are actually just little images your keyboard however passes an hexadecimal code to your computer which translates that code to an image. Like when typed a uppercase Z you actually passed (0x5A) or lowercase z (0x7A). print ord('Z'); Type your japanese lowest- (A 0x41) and highest character (Z 0x5A) for each of the tree different types afterwards check if the typed character falls within any of these ranges: $ascii = ord($char); if ($ascii >= ord('A') && $ascii <= ord('Z')) { //$ascii is between A and Z }
  19. A little fix. if (file_exists($fullPath)) { require_once($fullPath); break; }
  20. Don't include each and every class. It's possible you don't need the half of 'em at that time. I don't encourage the use of __autoload() as spl_autoload_* functions allow for more flexibility and allows to register multiple autoload functions to load classes from multiple resources. spl_autoload_extensions('.php,.php5,.php4');//allows to run 4, 5 & 6 alongside. In the event a filename is found for .php, .php5 and .php4 then only .php is included. // Initializes the autoload queue (FIFO) spl_autoload_register('autoloadLibraryClass'); //spl_autoload_register();//uses default implementation of spl_autoload() function autoloadLibraryClass($className) { global $libraryDirectory; $extensions = explode(',', spl_autoload_extensions()); foreach ($extensions as $extension) { $extension = trim($extension); $fullPath = implode(DIRECTORY_SEPARATOR, array($libraryDirectory, $className . $extension)); if (file_exists($fullPath)) { require_once($fullPath); } } if (!class_exists($className)) { //class still not loaded. } }
  21. Yep it's javascript. <div id="preview"></div> <textarea rows="5" cols="50" onchange="updatePreview(this)"></textarea> <script type="text/javascript"> <!-- function updatePreview(e) { var id = document.getElementById("preview"); id.setNodeValue(e.getNodeValue()); } //--> </script> I'm no JavaScript expert so the code may be a bit off. I used the DOM API but I'm not sure in how far browsers actually support this.
  22. Actually you can do this quiet easy: CREATE TABLE products ( products_id INTEGER NOT NULL AUTO_INCREMENT, products_categories_id SMALLINT, products_series_id SMALLINT, # is product part of some series? products_users_id SMALLINT, # used to sort on top submitter products_type VARCHAR(32), # used to sort on div layout, table layout, .. products_preview_count SMALLINT, # used to sort on most reviewed products_download_count SMALLINT, # used to sort on most downloaded products_added_date DATETIME, # used to sort on newest KEY fk_products_categories_id (products_categories_id), KEY fk_products_series_id (products_series_id), KEY fk_products_users_id (products_users_id), PRIMARY KEY (products_id) ); CREATE TABLE products_series ( products_series_id SMALLINT NOT NULL AUTO_INCREMENT, products_series_title VARCHAR(64), products_series_description TEXT, PRIMARY KEY (products_series_id) ); CREATE TABLE products_ratings ( # used to sort by most rated products_ratings_products_id INTEGER NOT NULL, products_ratings_rating TINYINT, # number from 1 to 127 possible products_ratings_count SMALLINT, # times voted for that specific number PRIMARY KEY (products_ratings_products_id, products_ratings_rating) ); #INSERT INTO products_ratings (products_ratings_products_id, products_ratings_rating) VALUES (1, 5) ON DUPLICATE KEY products_ratings_count = products_ratings_count + 1 CREATE TABLE categories ( categories_id SMALLINT NOT NULL AUTO_INCREMENT, categories_name VARCHAR(32), PRIMARY KEY (categories_id) );
  23. http://celestial-star.net/layouts/type/div/ euhm.. looks like they are going to make it you easy in finding out how they did it.
  24. Use sessions. session_start(); if (!isset($_SESSION['urls_visited'])) {// 'urls_visited' doesn't exist yet meaning this is the first page the user has visited. $_SESSION['urls_visited'] = array(); $_SESSION['urls_visited'][] = $_SERVER['PHP_SELF'];//register the current page as visited. } else {// 'urls_visited' exists meaning he has visited atleast one page. //if (!in_array($_SERVER['PHP_SELF'], $_SESSION['urls_visited'])) {//if you want unique pages visited then uncomment this however you will lose the order in which he visited them. $_SESSION['urls_visited'][] = $_SERVER['PHP_SELF']; //} }
×
×
  • 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.