Jump to content

dj-kenpo

Members
  • Posts

    155
  • Joined

  • Last visited

    Never

Everything posted by dj-kenpo

  1. AHH! I didn't know but it all makes sense now!! that's why the query worked fine in phpmyadmin AND on the script, I ahd no idea updating 0 rows would be considered OK.. I guess I can see why, but at the same time, sorta not.. using mysql_affected_rows works perfect
  2. envexlabs, result isn't needed there as it's the insert, by that point I don't need to know the result. roopurt18: timestamp is int(15). the querys individually work a-ok, but inside the script it ceases to work. it doesn't seem to return false for some reason. even in phpmyadmin, I can call the update command on an empty table and while it doesn't work, it also doesn't complain with any errors...
  3. can't figure out what I'm doing wrong here and it's really annoying! $month = date("F"); $date = date("d"); $year = date("Y"); $Timestamp_today = strtotime ("$month $date $year"); $query ="UPDATE site_stats_bots SET clicks = clicks+1 WHERE Timestamp='$Timestamp_today' AND User_ID='$User_ID'"; $result = mysql_query($query)or print ("Can't update<br />" . mysql_error()); if ($result == false) { $query = "insert into site_stats_bots (User_ID, clicks, Timestamp) values ('$User_ID', '1', '$Timestamp_today' )"; mysql_query($query); } I want it to update the bots stats for today, and if there is no row for today, create one. the query runs, but there's NO ERROR 'or print ("Can't update<br />" . mysql_error());' yet, no data goes into the databse. no data, no error, it just silently ignors me.
  4. there's an api, but it's .net asp stuff, not php.
  5. is it possible posible via a header to detect if the url (or $_get["title"] in my case) has underscores and if so send to the 404 page? my old urls had underscore, the new ones use more standard dashes, and the bots are all still roaming the old pages (which don't work and have errors) so I'd like to tell them to not go there I guess via 404..
  6. so you're saying store the short term (current day) stats in mysql, then move the individual completed days into a flat txt file?
  7. even with 100k growth per user per day? with 100 users that's 10mb's per day.... that's alot of excess
  8. I'm just looking for peoples opinions/suggestions. I'm have a cms and I want site stats built in, thus apache's stats or cpanel etc don't cut it for multiple users. I have a working stat query below, the problem is, in a short time 12 hours, it's grown to 109k with 500 records. now I'm not adding a row for every person, I create a session, and if they already have a row, I update clicks (page clicks) as you can see. still, it's big, the bots are eating it, so I figure, why not just create a separate table for bots, with 1 row per day and a click count. there, smaller. but with multiple users, and lots of normal hits, this will still grow quite large very fast! so I'm wondering if flat text files would be a better solution? but perhaps opening and writing to a text file constantly gets very slow? I'm confused... if(!isset($_SESSION['visitor'])){ $visitor_IP = $_SERVER['REMOTE_ADDR']; $visitor_browser = $_SERVER['HTTP_USER_AGENT']; $visitor_referer = strtolower($_SERVER['HTTP_REFERER']); $visitor_page_requested = $_SERVER['REQUEST_URI']; $_SESSION['visitor']=session_id(); $visitor_session_id = session_id();//varchar 32 //sql call $query = "insert into site_stats (User_ID, session_id, page, time, referrer, browser, ip, clicks, Timestamp) values ('$User_ID', '$visitor_session_id', '$visitor_page_requested', '$visitor_Timestamp ', '$visitor_referer', '$visitor_browser', '$visitor_IP', '1','$visitor_Timestamp' )"; @mysql_query($query); //print "$query"; } elseif(isset($_SESSION['visitor'])){ //else update time and page_clicks? $visitor_session_id = $_SESSION['visitor']; $query ="UPDATE site_stats SET time='$visitor_Timestamp', clicks = clicks+1 WHERE session_id='$visitor_session_id'"; @mysql_query($query);//or print ("error.<br />" . $result . "<br />" . mysql_error()); //print "$query"; }
  9. this didn't work either if(!session_is_registered("visitor_session_id")){ $visitor_session_id=session_id(); session_register("visitor_session_id"); print "$visitor_session_id";
  10. Hello, I'm trying to generate and then get the session id right away as I'd like to put it in a databse right away as well upon inital page view, but I clearly don't understand sessions as this is not working <? session_start(); $_SESSION['visitor']=session_id(); $visitor_session_id = session_id(); ?> this only works AFTER I refresh the page I need to get it right away though thanks
  11. I can't really be of help other than to bump this as it's an issue I think about alot too. there's always a trade off in how many sql calls to make, how much cpu to eat, how much memory to use. I'm curious, with 10k concurrent users, currently with the way you're doing things what sort of drain does thta cause for you, ie what sort of server /plan do you run that from? what type of site is it?
  12. I'm not echoing them. I'm storing them incase they need to be echoed later on, rather than doing on demand sql queries @btherl: I just started reading your post, and it blows my mind how much memory php eats, but,... when you talk about using a serialized string instead, while you save memory, you cost cpu, and in the end, cpu is more costly than memory, but perhaps you talk about that too, I'm only a paragraph in
  13. while I see the importance of this things are changing rather rapidly these last 2 years, the percentage of non windows clients continues to increase, people browsing the web on a wii, a treo, an iphone, not to mention a very steep increase in macintosh sales. so these extra little things that only work with windows are garnering less importance, as that little 3% non internet explorer win2000/xp group steps up to a much, much different place with firefox/mac's, hell, pc's with the mac os installed on them, etc etc etc. I wouldn't personally design anything with windows only in mind the same as I wouldn't simply design a site that runs fine in firefox/opera and say screw IE. it's gotta work in everything. I think php's real power is in efficiency, it takes less cpu power to run it, thus, per server you can host more hits/pages, and thus in the long run, save ALOT of money depending on the site. on large sites a few hundred dollars a month is all the convincing I need. of course it all comes down still to the coder, bad code is bad code no matter what language and there's always things like cake or ruby that waste countless cpu cycles as, it's generic and not custom coded for a specific application.
  14. just wondering what performance costs there are etc... theoretical question.. say 500 items stored temporarily into an array variable with an id and title $temp_array[$ID] = $title; (title = varchar 150 character max) it's for a page where it may,.. or may not be called... but when it is called, it could be called 1 or 10 times (it's a search page...) so I'm wondering if it's more sensible to load into memory temporarily for a split second rather than do up to 10 mysql queries for the title.. again, assume an array with 500 items~ is it no point worrying about the 4k or, what even less? maybe 1k? I don't want to shoot myself in the foot as the site grows, I'm worried about speed and efficiency. thanks for any thoughts/ opinions
  15. wow... I had no idea identifiers existed... I seem to have spotty knowledge on mysql/php... thanks barand. you rule as always
  16. hey! so I'm doing a union based fullt-text query on 3 different tables. problem: I want to know what is what. ie is result 1 from table 1,2, or 3? here's my query, which works, but it's nonesense without being able to say what table the data came from (I can't build a url link to the result if it's unlcear what it is...) $main_sql = "SELECT ID, Title, urlTitle, Timestamp, Entry, MATCH(Title, Entry) AGAINST ('$searchstring' IN BOOLEAN MODE) AS score FROM journal WHERE User_ID='$User_ID' AND MATCH(Title, Entry) AGAINST ('$searchstring' IN BOOLEAN MODE) UNION SELECT ID, NULL, NULL, Timestamp, Entry, MATCH(Entry) AGAINST ('$searchstring' IN BOOLEAN MODE) AS score FROM cv_entries WHERE User_ID='$User_ID' AND MATCH(Entry) AGAINST ('$searchstring' IN BOOLEAN MODE) UNION SELECT ID, NULL, NULL, Timestamp, Entry, MATCH(Entry) AGAINST ('$searchstring' IN BOOLEAN MODE) AS score FROM news WHERE User_ID='$User_ID' AND MATCH(Entry) AGAINST ('$searchstring' IN BOOLEAN MODE) ORDER BY Timestamp DESC";
  17. "Should I go back to using sessions for passwords?" god yes. in comparison to cookies anyways... md5 the password, store it in the session, and then check on EVERY single page if a db query for the password + md5 of it, matches the session value
  18. @Daniel oh man, do I ever feel like a noob.... I'm no js guy so i didn't know it would still submit, the code works perfect! Thanks! (I might be a little anal or paranoid, but still... I'd like to hide my structure as much as possible......)
  19. I don't really get what you're saying, if you think it would work though and could back it with some sample htaccess code I'm all for trying it. what you're saying is a redirect and then a rewrite? if I understand at all? I still don't see how it would work, but form gets are rather different so i wouldn't be too surprissed if it worked somehow and I just overlooked something very basic...
  20. htaccess can't rewrite it that way, as the form is sending the url data to the browser... it's like asking htaccess to find links on a page and rewrite them, doesn't work that way, but thanks for the thought anyways
  21. I'm already using htaccess, as I said, (that portion is fine) the problem is the get from not wanting to format the search string in any way but the default.. ugly way... @Daniel the javascript method is really smart, but I'd like to not corner myself is a user has javascript disabled...
  22. is it possible to control the URL sent from a web form of the GET type? write now I have my little search form, user types word(s) hits search, but instead of "http://domain.com/search.php?words=word1+word2" I'd like to take advantage of my htaccess and rewrite to search/word1+word2. I can do this easy in htaccess, but how do i get the FORM to send the url THIS way? anyone with experience in controlling form urls? thanks!
  23. hmmm but by that logic then why store it in the db at all? if you're checking if the file exists, why do a first look up? we already know the name "$user_ID.jpg". not sure if I see the logic mjdamato
  24. just wondering what's faster, an sql query or physiclly looking checking if a file exists. exact situation: user image icon for a forum. is it faster to check if $user_id.jpg exists, if so show it, if not sow generic icon. or, store filenames in an sql table and query for the filename under that user_id and then display? I have no need for multiple images for the same person, which is where sql would make it better, I'm just wndering how slow or fast it is to phyiscly look for a file WHILE the script is generating. I'd imagine it might be fast as includes are fast right? and that's just file etc stuff.... thanks!
  25. I think I shot myself in the foot. I have a photo album, and I'm using the follwoing htaccess code RewriteRule ^photos/(.*)/(.*) /photos.php?album=$1&pic=$2 works fine, here's the PROBLEM, some album titles are in folders, some are not... if I change it to RewriteRule ^photos/(.*)/(.*)/(.*) /photos.php?folder=$1&album=$2&pic=$3 though, then if there is no folder, it'll screw up and send the title name to folder and pic number to title... is there any fix for this ? can anyone think of anything? other people had to have faced this...
×
×
  • 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.