Jump to content

deansatch

Members
  • Posts

    300
  • Joined

  • Last visited

Everything posted by deansatch

  1. I have built a cms with a pretty secure login which only I will be using. I wanted to add some extra security and make it so that it can only be accessed from one physical PC. My ip changes every few days so I can't really trust that method. Is there some way I can identify my own PC so that any other computer that opens the login page will be rejected access automatically? Does the computer have it's own unique id that php can access?
  2. Does anyone know where I can find a really simple barebones facebook connect tutorial. All I want to be able to do is allow my members to update their facebook status. My site currently allows members to post a one line status on their membership profile page (stored in db) and I just want that same message to post to their facebook status at the same time. A bit like if you were to post a twitter feed and have it show on facebook status too. Is this possible, since the comments are stored in my database in a certain way? My members also have the ability to delete any posts via my site...will they remain on their facebook page? Any help is much appreciated.
  3. anyone? Also, the search returns nothing if I search for a word with an apostrophe in it(even though it is in the db) e.g. "let's" = no results but $actname = let's I have added mysql_real_escape_string() but it made no difference.
  4. I need to use a fulltext search but there are a couple of columns that will contain three letter words. My host won't lower the minimum letter length so I had to come up with a different solution. Here it is: $separate_words = explode(" ", $_POST['search']);//create an array of words //run through the array and extract the 3 letter words foreach($separate_words as $three_letters){ if(strlen($three_letters)==3){ //check the existence of the 3 letter words in the relevant columns then get their id's $query = mysql_query("SELECT id FROM table_acts WHERE actname='$three_letters' OR acttype='$three_letters' OR musictype='$three_letters'"); while($row=mysql_fetch_array($query)){ $id .= $row['id'].','; } } } //fulltext search BUT also include results from matching id's too $query = mysql_query("SELECT *, MATCH(actname, country, county, musictype, acttype, music) AGAINST('".$_POST['search']."') AS score FROM table_acts WHERE MATCH(actname, country, county, musictype, acttype, music) AGAINST('".$_POST['search']."') or id IN ($id 0) ORDER BY SCORE DESC")or die(mysql_error()); while($row = mysql_fetch_assoc($query)){ $actname = $row['actname']; $country = $row['country']; $county = $row['county']; $musictype = $row['musictype']; $acttype = $row['acttype']; $music = $row['music']; echo "<p>$actname - $country - $county - $musictype - $acttype - $music</p>"; } It works fine, BUT, the relevance order is all messed up and seems to put the 3 letter candidates last. Is this going to be too much load on the server as my member database grows? If not, how can I get the relevance order to work a bit better?
  5. Thanks for that. call_user_func_array() is a new one for me.
  6. I have a set of functions which contain different elements of a page. I want to be able to reorder how they appear on a page by pulling the order from the db. e.g. - want to be able to reorder the calling of these functions. display_news(); display_memberlist(); display_features(); Would I have to assign the ordering to the div id and rely on absolute positioning in css, or can I get php to dynamically call each funtion in any order?
  7. Aha! Thanks, that got me thinking! I just had to put $x=0; $y=0; before and at the end of the loop.
  8. I am using readdir in a while loop to convert a folder full of jpg images to square thumbnails. If I set $source as the name of one file and run the script it creates a perfect square thumbnail. If I run it as it is to do all the images, it creates square thumbnails but crops them wrong as if it is taking the size info for one image from the previous or next image. if($handle = opendir('act-gallery')){ while (false !== ($source = readdir($handle))) { if ($source != "." && $source != ".." && $source != "thumbs") { //echo $source."<br />"; $dest2 = "act-gallery/thumbs/".$source; $thumb_size = 132; $size = getimagesize('act-gallery/'.$source); $width = $size[0]; $height = $size[1]; if($width > $height) { $x = ceil(($width - $height) / 2 ); $width = $height; } elseif($height > $width) { $y = ceil(($height - $width) / 2); $height = $width; } $im = imagecreatefromjpeg('act-gallery/'.$source); $new_im = ImageCreatetruecolor($thumb_size,$thumb_size); imagecopyresampled($new_im,$im,0,0,$x,$y,$thumb_size,$thumb_size,$width,$height); imagejpeg($new_im,$dest2,100); imagedestroy($new_im); } } closedir($handle); } This works:(but only one image at a time.) $source= "image1.jpg"; $dest2 = "act-gallery/thumbs/".$source; $thumb_size = 132; $size = getimagesize('act-gallery/'.$source); $width = $size[0]; $height = $size[1]; if($width > $height) { $x = ceil(($width - $height) / 2 ); $width = $height; } elseif($height > $width) { $y = ceil(($height - $width) / 2); $height = $width; } $im = imagecreatefromjpeg('act-gallery/'.$source); $new_im = ImageCreatetruecolor($thumb_size,$thumb_size); imagecopyresampled($new_im,$im,0,0,$x,$y,$thumb_size,$thumb_size,$width,$height); imagejpeg($new_im,$dest2,100); imagedestroy($new_im);
  9. Thanks a lot. That works. I understand the code apart from the $0 part. Could you explain that bit please? I hate not knowing why something works.
  10. I want to bold a search term in my search results. To make it not case sensitive I used str_ireplace(). str_ireplace($_POST['search'], '<strong>'.$_POST['search'].'</strong>',$article); This works but of course it replaces the words lose their original case. e.g. $_POST['search'] = 'hello' $article = 'Hello world!' The article will end up looking like "hello world!" instead of "Hello world!" Is there a better way to insert some strong tags either side of the non-case sensitive word without replacing it? EDIT: Also, I have noticed that this won't work when the article is: 'Once upon a time there was a dog.' And $_POST[search'] = 'time dog' There must be a better way of doing this.
  11. Thanks McGyver! Is a 301 redirect the best way to do that?
  12. Should this: $header = escape_data($_POST['category_id']); not be: $category_id= escape_data($_POST['category_id']); ??????
  13. First thing I notice is your html is wrong. You have a closing tag on your textarea Change: <textarea name="first_para" cols="60" rows="6" /></textarea> To: <textarea name="first_para" cols="60" rows="6"></textarea> for a start
  14. I have a site where 2 domains are mapped to the same hosting account. e.g. domain.co.uk & dom-ain.co.uk. When a user lands on the site ad domain.co.uk and clicks "add to cart" they then start a session. But if they are redirected to dom-ain.co.uk, the session is lost. Is there a way to keep it on both? Or is there a way (search engine friendly) to make only one of these domains usable. I could do a 301 redirect on one of the domains so that the site is only viewable with one domain, but will I be penalised by google for redirecting the domain?
  15. Sorted! html_entity_decode($row['venue'], ENT_QUOTES, "utf-8" );
  16. so if it is converted, why doesn't the slash get added?
  17. I checked the db and it is stored as Mary&#39;s Why doesn't it output to my source code as that???
  18. check the source code of your form before submitting to see if the $ref has a value. Also add "or die(mysql_error())" to your db query
  19. install a free web stats program?? awstats, tracewatch etc...
  20. That may be an option, but still doesn't answer my question. Why isn't addslashes working?
  21. Yes. But you will have to make the script run in small portions depending on your host. If you run all 10k mail()'s in one go, your host will probably stop the script and give you a warning.
  22. fair enough: $li = '<ul>'; while ($row = mysql_fetch_assoc($query)) { $venue =$row['venue']; $li .="<li >addslashes($venue)</li>"; } $li .= '</ul>'; if($venue !=''){echo $li;} }
  23. on your dumbed down code you did the echo using shortags. Try <?php instead of <? Also, if you are using a form, why not use method="post" and then echo $_POST['name'];
×
×
  • 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.