Jump to content

sohaibshaheen

Members
  • Posts

    23
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://t-bait.blogspot.com/

Profile Information

  • Gender
    Male
  • Location
    Pakistan

sohaibshaheen's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, I want to give users their own urls e.g. username.site.com for which I need to mod rewrite so username.site.com ::: points to site.com/profile.php?user=username (masked - no redirect) I have accomplished above thing already but I also want to point username.site.com/profile to point to site.com/profile.php?user=username , which I cannot accomplish somehow.. Here is what I have:: RewriteCond %{HTTP_HOST} !^(www\.)?site\.com [NC] RewriteCond %{HTTP_HOST} ^([^.]+)\.site\.com/?$ RewriteRule ^$ /profile.php?user=%1 [L] Please help me.
  2. I didn't get your question completely but I guess you should add the where clause in sql statement for clicked=0 or boat=0. Also you can't put anything in ID randomly.. because ID 1000 may not exist (i.e. if deleted or too large). $sql="SELECT * FROM grid"; $result=mysql_query($sql); $count=mysql_num_rows($result); $randcell = rand(0,$count-1); $sql="SELECT * FROM grid WHERE ID='$randcell' && clicked='0'"; $result=mysql_query($sql); $row = mysql_fetch_array( $result ); Hope this helps.
  3. Hey! I am back with a new question... I want to create my own api which returns JSON data to the user when he opens a page: http://musicclan.com/json.php?format=json When I place this "json.php" file on my localhost and create "json_parser.php" to handle output it works fine but when I place that "json.php" at remote location like one above and try to access it on my localhost it doesnot respond. Note: I can access flickr and facebook APIs on my localhost. ... and JSON is also valid as I tested on some site. JSON_PARSER.PHP <head> <script src="jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> function loadFlickr() { $.getJSON('http://musicclan.com/json.php?format=json', function(data) { $("#feed").append(data.posts.post.foo+"<br/>"); }); } </script> </head> <body> <script type="text/javascript"> loadFlickr(); </script> <div id="feed"></div> </body>
  4. I am sorry I have absolutely no idea where this question fits in this forum bcoz its related to PHP , MySQL and Javascript... :-\ So here is my question .. I use MySql database to store posts.. where 'postdate and time' is saved using 'CURRENT_TIMESTAMP' of MySql that offcourse gives "2010-08-31 09:47:10" format... When I have to calculate when the post was posted just before loading the posts on users wall e.g. "2 min ago"... I take the 'postdate and time' from database then use strtotime() function in php to convert it to string you know since jan 1 1970. Now this time stamp is sent to javascript function which uses 'Date' Object to create current time and then 'getTime' to get the string like one Mentioned earlier. it then calculates the difference and displays it.. Just to inform you.. I used javascript to I may refresh "posted since" periodically using "SetInterval()" But the problem here arises. There is difference of 1 Hour and 24 Sec in both times....... Sorry If I confused you... But the problem is simple. In javascript date object and MySql --> strtotime() there is time difference... How I can correct it ??? Plz Help ... Codes: 1. function to convert str to time function change($date){ $time_early=strtotime($date); return $time_early; } 2. javascript Code to check "Post Since" function calc_difference() { $("[name=posttime]").each(function() { var current=$(this).attr("id"); localtimevalue = new Date(); d = localtimevalue.getTime(); var d= parseInt(d)/1000; var diff=d-parseInt(current); var diff=parseInt(diff); var min=parseInt(diff/60); var hours=parseInt(diff/3600); var days=parseInt(diff/86400); var months=parseInt(diff/2592000); var years=parseInt(diff/31104000); if( min==0 ){ $(this).text("Posted: "+diff +" seconds ago "); } if(min>0 && hours==0 && days==0 && months==0){ if(min==1){ $(this).text("Posted: a minute ago "); }else{ $(this).text("Posted: "+min +" minutes ago "); } } if(min>0 && hours>0 && days==0 && months==0){ if(hours==1){ $(this).text("Posted: an hour ago "); }else{ $(this).text("Posted: "+hours +" hours ago "); } } if(days>0 && months==0 && years==0){ if(days==1){ $(this).text("Posted: a day ago "); }else{ $(this).text("Posted: "+days +" days ago "); } } if(months>0 && years==0 ){ if(months==1){ $(this).text("Posted: a month ago "); }else{ $(this).text("Posted: "+months +" months ago "); } } if(years>0){ if(years==1){ $(this).text("Posted: a year ago "); }else{ $(this).text("Posted: "+years +" years ago "); } } }); } Javascript function is called on load and Jquery's .each function is used to update all post's time.
  5. You can implement that using Jquery... Although that will be difficult job but .scroll() and .scrollTop() are fucntions that you need! Hope that helps
  6. Forgot to mention: You will receive $_GET['id']; on the loading php page
  7. sure there is: just attach onclick with the album e.g. <div id="11" class="album" onclick="load_images(this);"> whatever .... </div> function load_images(obj){ var id=$(obj).attr("id"); $.get("load_from_page.php", { id: id}, function(data){ $('#where_to_load').html(data); }); } } Hope this answers the question
  8. What if the rand output doesnot equal row value.. It may produce 100 when u have 30 results only...
  9. This is pretty Simple: change your css file to ... body{ cursor: wait; } and then use this fucntion in head <script type="text/javascript"> window.onload=function(){ document.body.style.cursor='auto'; } </script> Hope this answers the question.
  10. BlackTyger: I am forced to assume you are novice.. So let me explain it to you before making an suggestion. The search script you are using is vulnerable and totally non-workable. Let me shine some light on it. First of all you are using the variable from GET method in mysql_search query directly , suppose some one searches.. query = " 'sony " then your query will crash as single quote breaks the syntax. So first thing you need to do is remove quotes using php functions e.g. $new_text=mysql_real_escape_string($_GET['query']); and use $new_text as search variable. Secondly. When you search "sony television" it actually looks for exact phrase " sony television " whereas you need to look 'sony' and 'television' separately at different locations in string. So what you need to do is to : break the string into array and then look for each item separately. e.g. $broken_string=explode(" ",$_GET['query']); now look for $broken[0] and $broken[1] one by one ... This is how it may be implemented: foreach($broken as $value){ // look for $value in string and print } Hope it answers the question!
  11. As much as I can understand -- you just want to display files that are not in database but in directory. To this question I know the answer: Ok: Lets start.. Keeping in mind the function you are using to print directory files and the fact that you have basic knowledge of PHP. This must be simple to implement. Now in your display fucntion when you are about to print the file name. Use something like this $result = mysql_query(" SELECT * FROM table WHERE image_name='$file_name' ") or die(mysql_error()); if(mysql_num_rows($result)>0){ // dont print }else{ print file } It is that simple. Bye
  12. This id pretty simple. All you have to do is: $text="hello I am doing well http://www.google.com ok"; preg_match("/[a-zA-Z]+[:\/\/]+[A-Za-z0-9\-_]+\\.+[A-Za-z0-9\.\/%&=\?\-_]+/i",$text,$url); $new= "<a href=\"$url[0]\">$url[0]</a>"; echo preg_replace("/[a-zA-Z]+[:\/\/]+[A-Za-z0-9\-_]+\\.+[A-Za-z0-9\.\/%&=\?\-_]+/i",$new,$text); And you are done...
  13. This is what you exactly need!! $result = mysql_query(" SELECT * FROM table WHERE column NOT REGEXP '^[a-z]' ") or die(mysql_error()); If I am not wrong! As far as I tested this is case insensitive match so a-z and A-Z are same!
×
×
  • 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.