pouncer
Members-
Posts
324 -
Joined
-
Last visited
Never
Everything posted by pouncer
-
This is my functions in my class Lookup function Get_Query_String($string) { $wordArr = str_word_count($string, 1); $ret = ""; foreach ($wordArr as $word) { if (this->Is_Word_In_Search($word) == TRUE) { $ret .= $word; } } return $ret; } function Is_Word_In_Search($word) { $file = "../search_strings.txt"; $fp = fopen($file, "r"); while (!feof($fp)) { $line = fgets($fp, 4096); $line = trim($line); if ($line == $word) { return TRUE; break; } } return FALSE; } then in my collection file i do: $search = new Lookup(); echo $search->Get_Query_String($word); it gives the bool error
-
when i try to call the function from the same class file lie this if (this->Is_Word_In_Search($word) == TRUE) { $ret .= $word; } i get syntax error, unexpected T_OBJECT_OPERATOR on line 11 line 11 is if (this->Is_Word_In_Search($word) == TRUE) {
-
function Is_Word_In_Search($word) { $file = "../search_strings.txt"; $fp = fopen($file, "r"); while (!feof($fp)) { $line = fgets($fp, 4096); $line = trim($line); if ($line == $word) { return TRUE; break; } } return FALSE; } is that ok guys, if it finds the word in the file, i want it to return true, otherwise false..
-
yep, I want to match with for e.g, %cat% OR %dogs% etc. Thanks for confirming the correctness.
-
can we queries where for LIKE where we can search for 2 strings in the description? like mysql_query("SELECT * FROM collections WHERE description LIKE %something% OR description LIKE %somethingelse%"); is this complettely valid and is my syntax correct guys?
-
because i send each word to a site to see if its a noun or an adjective
-
thanks clown. ive got this $string = "My favourite DVD's!"; $un_needed = array("!", "'s", "'"); $string = str_replace($un_needed, "", $string); any other characters you can think to replace with blank?
-
and also i cant use $string=str_ireplace("'s","",$string); //only works for php 5 because mine isnt php5 any other ways to replace "'s" with "" ?
-
is there a way i can put all my replace in 1 function like str_replace("'", "", ".", "", ...... etc...)
-
str_replace for what mate? hmm, im not sure how to do it. can anyone give any sample codes?
-
Say for e.g, i have a sentence: "Hello, my name is Johnny and I like DVD's" How do I extract each word from the sentence and echo it? and also, i want remove any ' from any words, and also if the word ends in s, i want it to remove the s. so with this sentence it shud echo: Hello my name is Johnny and I like DVD can anyone help me achieve this?
-
getting the most expensive and cheapest price..
pouncer replied to pouncer's topic in PHP Coding Help
any experts around who can help me with this? -
foreach($itemNodes as $item) { $price = $item->getElementsByTagName('CurrentPrice'); echo $price->item(0)->nodeValue . "<br>"; } It echos a list of prices.. fine. But how can i somehow grab the highest/lowest price from it!
-
can someone please help on the rename part?
-
thanks. where do i put the file_exists part? and also, if the file does exist how do i rename it the way i put in my 1st post? any help anyone?
-
I've got this code here which uploads a profile image file.. if (isset($_POST['Submit'])) { $_accepted_extensions = array('.jpg', '.bmp', '.gif', '.JPG', '.BMP', '.GIF'); $tmp = pathinfo($_FILES['imageupload']['name']); if (!in_array('.' . $tmp['extension'], $_accepted_extensions)) { echo "The image you attempted to upload is of the wrong file type."; } else { $target_path = "../profile_images/"; $nm = basename($_FILES['imageupload']['name']); $target_path = $target_path . $nm; if (move_uploaded_file($_FILES['imageupload']['tmp_name'], $target_path)) { echo "The file ". $nm . " has been uploaded to your profile."; $user_id = $_SESSION['UserID']; $Image_URL = "thumbnail.php?im=" . "profile_images/" . $nm; $profile = mysql_query("UPDATE user_profile SET Image_URL = '$Image_URL' WHERE user_id = '$user_id' ") or die (mysql_error()); } else echo "There was an error uploading the image, please try again."; } } I want to change it though to work with: if the file already exists on the ftp, rename the filename (possible adding a random 6 digit number to end of filename?) and upload it. also to store this new filename in the sql table . can anyone help me?
-
yep, it works perfectly.. thanks! you saved me having creating the other table and stuff!
-
so say my item_table has 70 items, will that return the latest 9 items? ie. records 61,62,63,64,65,67,68,69,70?
-
I'm going to create a table in my database called 'latest_items' which should store the latest 9 items (which my users upload etc) but how would i display the latest 9 items. and what if the table already contains 9 records.. and a user uploads a new item, how would i change the table i hope someone can help me out!
-
they didn't work guys, any ideas peeps?
-
function get_Keyword() { return $this->row['keyword']; } if the keyword is more then 10, i want it to show the first 10 letter with .. on the end of it, otherwise just to return the whole string? e.g keyword = "mr bean excellent DVD" the function should return: mr bean ex..
-
Barand, absolutely awesome - that fixed it.
-
<table width=90% cellpadding=0 cellspacing=10 border=0 align=center><tr><th></th><th></th><th></th></tr><td align=center> <img src="../thumbnail.php?im=collection_items/John_images/godfather1.jpg"> <br> <a href="manageitem.php?item_id=7">Manage</a> <br> <a href="delete_item.php?item_id=7">Delete</a> </td><td align=center> <img src="../thumbnail.php?im=collection_items/John_images/carlitos-way.jpg"> <br> <a href="manageitem.php?item_id=8">Manage</a> <br> <a href="delete_item.php?item_id=8">Delete</a> </td><td align=center> <img src="../thumbnail.php?im=collection_items/John_images/godfather1.jpg"> <br> <a href="manageitem.php?item_id=9">Manage</a> <br> <a href="delete_item.php?item_id=9">Delete</a> </td><tr><td align=center> <img src="../index_images/create_avatar.gif"> <br> <a href="manageitem.php?item_id=12">Manage</a> <br> <a href="delete_item.php?item_id=12">Delete</a> </td></tr><td align=center> <img src="../index_images/create_avatar.gif"> <br> <a href="manageitem.php?item_id=19">Manage</a> <br> <a href="delete_item.php?item_id=19">Delete</a> </td></table> </span></span><br> <span class="style15"> </span><br>
-
thats inside the loop! if ($i % 4 == 0) echo "<tr>"; echo "<td align=center> <img src=\"$image\"> $i <br> <a href=\"manageitem.php?item_id=$item_id\">Manage</a> <br> <a href=\"delete_item.php?item_id=$item_id\">Delete</a> </td>"; if($i % 4 == 0) echo "</tr>"; i want it to display by a 3 x 3 table.. all items going down the page