Jump to content

Lyleyboy

Members
  • Posts

    149
  • Joined

  • Last visited

Everything posted by Lyleyboy

  1. Superb, that works. The word is in the query and it replaces it nicely. I did think about the part word replacement issue. Didn't have the faintest idea of how to do it. I was thinking about wrapping everything so that I could find full words. Shoddy job I know.
  2. What about a nasty way to do it by setting a session variable to hold the product1 variable. Then if the session is set don't run the script again. If it's not set go for your life. Make sense? Im not a good php developer so I have to fudge things into working sometimes.
  3. The easy way would be to keep all the PDF's in the same folder (and nothing else) then create a form to select the files. Something like the below. <select name="file"> <?php $dir = opendir('server/pdf/'); while ($read = readdir($dir)) { if ($read!='.' && $read!='..') { echo "<option value='" . $read . "'>" . $read . "</option>"; } } closedir($dir); ?> </select>
  4. You could just unset the variables at the end of the function. unset($product1);
  5. Hi all, Trying to do a really simple swear filter. Don't need anything too fancy. So far I have <?php include('../../includes/inc.conn.php'); function swear($string){ $query = "SELECT word FROM bad_words"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ $word = $row['word']; echo $word . "<br/>"; $str = str_replace($word, "***", $string); } return $str; } $string_to_check = "shit cock"; echo $string_to_check; echo "<br/>"; echo swear($string_to_check); ?> This wont work but if I put $word = "cock"; instead of the row['word'] it works. Like the below. <?php include('../../includes/inc.conn.php'); function swear($string){ $query = "SELECT word FROM bad_words"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ $word = "cock"; echo $word . "<br/>"; $str = str_replace($word, "***", $string); } return $str; } $string_to_check = "shit cock"; echo $string_to_check; echo "<br/>"; echo swear($string_to_check); ?> Can someone tell me what's wrong. I can't see the difference.
  6. Really simple way would be to add the hours on. So any time zone is a whole number of hours plus or minus of gmt. Just work out the difference and before you post the date to the table add or subtract the difference. Very quick and dirty. :-)
  7. Hi all, I'm looking for some advice / ideas. I have to create a swear filter. I have a mysql table with a load of bad words in it. What I need to do is filter the content from a form and replace any bad words found. I have no ideas of where to begin. Help!
  8. So you need to change the wring length if statement. Still think the div needs to go atthe bottom as it's using variables that you haven't set yet
  9. Try putting the DIV code from the top down after all the php has finished. May work for you
  10. Do you mean three results or three charachters in your $search string.
  11. Try some thing like this <div id="wb_Shape2" style="position:absolute;top:-60px;left:-15px;<?php echo $div_height; ?>width:793px;z-index:-1;" align="center"> <img src="/Images/body_img.jpg" id="Shape2" align="top" alt="" title="" border="0"<?php echo $img_height; ?> width="793"> </div> <?php $search = $_GET['search']; if(strlen($search)<3) { echo "Your search must be at least 3 characters long."; $div_height = 'height:500px;'; $img_height = 'height="500"'; } else { $div_height = 'height:1200px;'; $img_height = 'height="1200"'; //connect to our database mysql_connect("localhost","***","***"); mysql_select_db("***"); //explode our search term $search_exploded = explode(" ",$search); foreach($search_exploded as $search_each) { //construct query $x++; if ($x==1) $construct .= "username LIKE '%$search_each%'"; else $construct .= " OR username LIKE '%$search_each%'"; } //echo out construct $construct = "SELECT * FROM members WHERE $construct"; $run = mysql_query($construct); $foundnum = mysql_num_rows($run); if ($foundnum==0) echo "You searched for <b>$search</b>. No results found."; else { echo "You searched for <b>$search</b><br>$foundnum result(s) found!<p><hr size='1' width='387'color='#E6E6E6'>"; while ($runrows = mysql_fetch_assoc($run)) { //get data $state = ucwords($runrows['state']); $url = $runrows['url']; $username = ucwords($runrows['username']); $imagelocation = $runrows['imagelocation']; if ($imagelocation == "") { $imagelocation = "./profileimages/noprofilepic.jpg"; } echo " <img src ='$imagelocation' width='100' height='105' border='0' align='left' style='padding-right:10px'><br> <b>$username</b><br> $state<br> <a href='$url'>View Profile</a><br><br><br> <hr size='1' width='387' align='left' color='#E6E6E6'> "; } } } ?> Try that, really quick and dirty but it may be what you're after.
  12. Not sure I'm getting the right end of the stick here or not but if you put all your query code inside the else then if they only enter an L all they will get is the strlen error message and no query will be executed. Hope that helps
  13. Thanks for that. My code is below (And not working) $handle_db1 = mysql_connect("localhost", "discover_lyle", "******") or die(mysql_error()); $handle_db2 = mysql_connect("localhost", "discover_lyle", "******") or die(mysql_error()); mysql_select_db("discover_discovery",$handle_db1); mysql_select_db("discover_messaging",$handle_db2); //do a query from db1: $query = "select * from users"; $which = $handle_db1; $result = mysql_query($query,$which) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo $row['username'] . "<br/>"; } //do a query from db2 : $query = "select * from dummy"; $which = $handle_db2; $result = mysql_query($query,$which) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo $row['id'] . "<br/>"; } My error is Table 'discover_messaging.users' doesn't exist Any help would be cool.
  14. Hi all, I'm after some advice. I am reasonable with php mysql but not great. What I have is a quickly growing project and database size limitations (Host driven). What I would like to do is to use two databases. At the moment I use one for all the users and photo galleries but I'd like to use a different one for the next bit of the project. My question is can I have two running together. If I have two comm includes at the start of the file will mysql just find the correct table from my queries. I hope I have explained this well enough but I'm not certain. If you need any more help let me know.
  15. Hi Thanks for the advice. I may have misled you. I'm looking for users to be able to upload a photo (which I have working) but for the sake of speed and usablility of the site I want the image to be automatically (as you can't reply on a user to do this) resized to say 600 px wide. I hope this clarifies my request.
  16. Hi all, I have had a search but not found anything of too much help. What I need is a script to take an existing image file resize it to 600 wide then save it back to the same folder/filename. I am a total newbie so please don't get too techie with me. Thanks in advance.
  17. Its a bit dodgy but couldn't you give the tab an id and suffix the session variables within that tab with the id? Bit crude and dirty but it could work.
  18. Thanks for that. I think I have mislead you. I have a table 'user detail' which has a field called 'night'. When the registration form is filled out the 'night' is populated from a different table called 'nights' (Imaginative aren't I?) So when the form to edit the users is displayed there will be a value in $row['night']. I can happily populate a text box with the value but I'd like to have a drop down populated from 'nights' table and then add the selected=selected attribute to the select element. I hope that make more sense. Sorry!
  19. Hi all, I have a users table, one of the fields is an evening (attendance to the club). I want to be able to show a form with (amongst other things) the evening name in a drop down list. I'd like to pull the evenings from a table and then check the selected to the one from the recordset. Does that make sense? Any pointers would be great. Thanks
  20. Hi all, Having a weird issue. I am trying to display the last modified data of a txt file in a sub folder. I am using a version of the below code. $myfile = filemtime('/path/to/file/file.php'); The date is showing as 1/1/1970. I'm prettry sure I didnt write it 7 years before I was born... I have the path set up as "sub/file.txt" would it require the absolute path?
  21. Hi all, I am fairly sure there is a way to do this but not certain. How can I detect the data sent via $_POST if I am not sure what the field names will be? The concept is that I'll have a lot of checkboxes with various names and I need to see what has been clicked. The names of the checkboxes will not be the same twice. Thanks
  22. Well there we are then. That easy huh? So that worked perfectly. My only problem is the understanding. Why didn't it work initially? Many many thanks
  23. I have a weird (or maybe not) issue. I'm trying to do a really basic bit of form validation. I'm using a friends server as it's his site. I've tested this on mine 1and1 in the UK. It works fine. Tried it on his, fasthosts and it fails. The crux of the problem seems to be that I am setting a variable inside an if statement. If I then try to use the variable outside the if I get an error undefined variable. I have even tried to define the variable as a dummy value before the if statement but I get the same error. My code looks like this if ($_POST['name']<""){ $errors = "1"; $name_error = "You did not enter your name!"; } if ($errors == "1") { echo "Errors"; } The error onscreen is below. Line numbers will be wrong as I have not published all the rubbish here. Notice: Undefined variable: errors in E:\domains\n\nicholaskirtonphotography.co.uk\user\htdocs\contact_process.php on line 35 Can anyone help as I am about to move the site to a different server. P.s. Fasthosts seem to think this is fine.
  24. Superb. I knew there would be an easy way. I was off doing logic checks and using an incremented counter.
  25. Hi all, I am in need of two queries from the same table. I have an ID which is an auto incremented number. There will be some gaps in the ID range. Query 1, I want to pull the record with the highest ID i.e. I have records 1,3,4,6,7,9,11,15,18,20,23 I only want to pull ID 23 Query 2, I want to pull the next five records i.e. 23,20,18,15 and 11 I hope this makes sense to someone. Thanks in advance
×
×
  • 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.