PHP - Help Finding Code Sorry
hi there all i need the code that adds the url to a page like in the new forums cheers.
you get a image of that website and the url of the page
can anyone help please
thank you
like if i type www,google.com <<< you get a image and link automaticly..
Edited by php-real-degree, 15 September 2014 - 05:07 PM. Similar TutorialsI have build a small form that take the zip code that user enter and if is on my list will redirect to a sub domain craigslist.
I was checking all the zip codes and is pretty hard to know to what bigger city to attribute the given zip code and for that I was thinking to a simple idea to use, I am not sure how much exact will be but I think will do the trick for the moment.
The zip code range start from 00501 to 99950.
I create a array with the biggest city shown in craigslist and the zip code that correspond.
Now the tricky part, what I will do with the rest of the zip codes and my idea is to measure the distance from one to another zip code and which zip code from the array is closer from given one to take it.
<?php $zip = $_GET['zip']; $z = array ( 36830 => array ( 'auburn.craigslist.org' ), 35242 => array ( 'bham.craigslist.org' ), 36301 => array ( 'dothan.craigslist.org' ), 35630 => array ( 'shoals.craigslist.org' ), 35901 => array ( 'gadsden.craigslist.org' ) ?> Exemple: $zip= 36870 // the code received from the user 36870 - $array= ( 'auburn.craigslist.org' ), (36830 = 40) (36301 = 569) (36911 = -41) // the minus will be excluded (....etc)After checking the zip code with the ones from array, the smaller score will attribute the sub-domain correspond from the array. I hope will don t be the case when will get the same result from two zip codes:) Now I am using this rule: $zip0 = (isset($z[$zip][0]) && $z[$zip][0] != '') ? $z[$zip][0] : 'craigslist.org/about/sites#US';and I was thinking to redirect the user for a page to enter the state and the city. But I wish to make it more precises and not to involved the user so much. But if there are any other suggestions I will be glad to hear them. I am trying to insert into my database and it's just not having non of it. No errors are comming up at all, but no data is getting passed through. Code: [Select] if(isset($_POST['sub'])) { include("../scrips/php/cms/database.insert.class.php"); $table = "blog_posts"; $title = $_POST['ArticleTitle']; $img = "2"; $post = $_POST['ArticleBody']; $aurthor_id = "1"; $category_id = "4"; $date_posted = "NOW()"; $values = array("$title","$img","$post","$aurthor_id","$category_id","$date_posted"); $fields = array('title','img','post','aurthor_id','category_id','date_posted'); //echo $values['0']."<br/>".$fields['0']; //$obj->ArticleInsert($table,$fields,$tvalues); $values_imploded = implode("','",$values); $fields_imploded = implode(",",$fields); $i = "INSERT INTO $table ($values_imploded) VALUES ($fields_imploded)"; mysql_query($i) or die( "<br>Query string: <br>Produced error: " . mysql_error() );; } Okay I'm done with searching for answers, working on this preg_match for about 3 hours now.
I'm looking for "($0.01/$0.02 USD)" in a string. The needle might be slighty different. Possible strings that I might look for is: (€xx.xx/€xx.xx EUR) where the EUR can be changed into USD, including its signs. Hi I have a file, that is copied from other files. All other files work perfectly. But, for some reason this one is throwing back an error. I've been over it so many time, but can't see whats wrong. Error: Fatal error: Call to undefined method stdClass::save() in /home/p/o/powtest/web/public_html/admin/lib/ajax_php/add_interests.php on line 28 add_interests.php Code: [Select] <?PHP require_once("../../../includes/initialize.php"); $flag = 0; $ID = $_POST['ID']; $type = $_POST['type']; $category = $_POST['category']; $interest = $_POST['interest']; $expInt = explode("\n", $interest); $DMOD = date('Y-m-d'); $TMOD = date('H:i:s'); $check_entry = Admin_interest::if_exists(clean_input_value($category)); if($check_entry == 0){ $new_category = Admin_interest::make($ID, clean_input_value($category), clean_input_value($type), $DMOD, $TMOD); if($new_category && $new_category->save()){ $CID = $new_category->id; $flag = 1; } } foreach($expInt as $expInts){ $check_entry = Admin_interests_sub::if_exists($CID, clean_input_value($expInts)); if($check_entry == 0){ $new_interest = Admin_interests_sub::make($ID, $CID, clean_input_value($expInts), $DMOD, $TMOD); if($new_interest && $new_interest->save()){ $message = 'Thank You: Your list Has Been Saved'; }else{ $message = "Sorry, There was an error"; } } } echo $message; ?> Class: Code: [Select] <?PHP require_once(LIB_PATH.DS.'database.php'); class Admin_interests_sub { protected static $table_name="admin_interests_sub"; protected static $db_fields = array('id', 'category_id', 'interest_sub', 'dateMod', 'timeMod'); public $id; public $category_id; public $interest_sub; public $dateMod; public $timeMod; public static function make($ID, $category_id, $interest_sub, $DMOD, $TMOD){ if(!empty($interest_sub)){ $interest = new Admin_interests_sub(); $interest->id = (int)$ID; $interest->category_id = (int)$category_id; $interest->interest_sub = $interest_sub; $kw->dateMod = $DMOD; $kw->timeMod = $TMOD; return $kw; }else{ return false; } } protected function attributes(){ $attributes = array(); foreach(self::$db_fields as $field){ if(property_exists($this, $field)){ $attributes[$field] = $this->$field; } } return $attributes; } protected function sanitized_attributes(){ global $database; $clean_attributes = array(); foreach($this->attributes() as $key => $value){ $clean_attributes[$key] = $database->escape_value($value); } return $clean_attributes; } public function save(){ return !empty($this->id) ? $this->update() : $this->create(); } public function create(){ global $database; $attributes = $this->sanitized_attributes(); $sql = "INSERT INTO ".self::$table_name." ("; $sql .= join(", ", array_keys($attributes)); $sql .= ") VALUES ('"; $sql .= join("', '", array_values($attributes)); $sql .= "')"; if($database->query($sql)){ $this->id = $database->insert_id(); return true; }else{ return false; } } public function update(){ global $database; $attributes = $this->sanitized_attributes(); $attribute_pairs = array(); foreach($attributes as $key => $value){ $attribute_pairs[] = "{$key}='{$value}'"; } $sql = "UPDATE ".self::$table_name." SET "; $sql .= join(", ", $attribute_pairs); $sql .= " WHERE id=".$database->escape_value($this->id); $database->query($sql); return ($database->affected_rows() == 1) ? true : false; } public function delete(){ global $database; $sql = "DELETE FROM ".self::$table_name." "; $sql .= "WHERE id=".$database->escape_value($this->id); $sql .= " LIMIT 1"; $database->query($sql); return ($database->affected_rows() == 1) ? true : false; } } ?> Any help finding this bug will be a big help. Thanks I am trying to find the URL to a directory TWO levels above the script level (if you know what I mean). For example.. the script sits at Code: [Select] http://www.domain.com/TestArea2/members/index.php BUT I need to find the path to Code: [Select] http://www.domain.com/TestArea2/ the nearest I get is... $domain = $_SERVER['HTTP_HOST']; $domain .= $_SERVER['REQUEST_URI']; echo $domain; // outputs www.domain.com/TestArea2/members/index.php Is there a simple method to do this or have I got to split the string and work backwards? Many thanks //calculate age $birthdate = "1978-04-26"; //birth date... actually being obtained from a database $today = date("Y-m-d H:i:s"); // The exact date $age = date_diff($str_birthday, $today); echo $age; I'd like a simple code to echo the age of someone with the mysql database information that's in their record. This doesn't work. I have no idea why. Nothing seems to work that I've found on the net. Please help. Thanks. My query is not finding the last recieptnum entry, it is finding the number 9 everytime for some odd reason. Im trying to incrementally increase this each time a reciept is created. $getreceiptnum = mysql_query("SELECT receiptnum FROM accounting WHERE agency = '$agency' ORDER BY receiptnum DESC LIMIT 1") or die(mysql_error()); $recieptarray = mysql_fetch_array($getreceiptnum); $recieptnum = $recieptarray['receiptnum']; echo $recieptnum; User submits 1 or more refrerences via a form. On the action page I want to check if any id's on the page match any values submitted in $_POST. Code: [Select] $Ref = $_POST['Ref']; $source = file_get_contents( 'E:/wamp/www/Project/File.php' ); $document = new DOMDocument; $document->validateOnParse = true; $document->LoadHTML($source); for($i=0; $i<count($Ref); $i++) { $ID = $document->getElementById('$Ref[$i]'); } I have a table on the source page with the same id as a reference contained in $Ref, but getElementById is not seeing/recognsing it. No idea why not. Im trying to find the time between the last database entry and the current time and then echo it so it says something like '2 minutes ago'. I tried doing: $last_post_gap = strtotime('NOW') - strtotime($topic_info->topic_last_post_time); $last_post_gap = date('i', strtotime($last_post_gap)); $last_post = date('F j, Y', strtotime($topic_info->topic_last_post_time)); if ($last_post <= '- 1 DAY') { $last_post = 'Yesterday at '.date("g:i a", strtotime($topic_info->topic_last_post_time)); } if ($last_post <= '- 1 MINUTE') { $last_post = 'Less Than 1 Minute Ago'; } else { $last_post = $last_post_gap.' Minutes Ago'; } but that just displays 0 minutes ago regardless of the time. Is there anything im missing? Howdy Colleagues,
I was wondering whether you know ways/websites/channels/magic owls to how to help find a job in USA as a programmer as in for relocating there while the company pays for the Visa and the travel expenses?
My land-lord's son found a job as a programmer in Texas and the company was generous and kind enough to pay his travelling expenses, as well for his wife and kid.
I have an account in Monster & Indeed and I send CVs very often, but no luck so far.
And I want to go there to work and live, not like some people to rely on welfare, I have worked my whole life.
Thank you!
BR,
Stefany
Hello. I think I have a little unique and difficult to solve problem that I really need to post here. I, as a counter-strike portal administrator, am running some CS servers. With automatical script, the server uploads demos (videos of gameplay) on FTP in this format: 101229154428.dem and so on. The number is a date in this format: year, month, day, hours, minutes, seconds => for the example it's 29th December 2010, 15h, 44m and 28s. Then I have a "report" page. The important part on it is that, there is a date in unix timestamp in each row like 1336837680 (29th december 2010, 15h, 47m, 00s). And now what I need: Find a demo that corresponds to the unix timestamp. If there is a timestamp 1336837680, it should find 101229154428.dem. You know what I mean, there is not one demofile, there are plenty. Just find the demo, that contains a record of the time used in timestamp. Pretty difficult, isn't it? I would love to see if anybody came up with anything. Best regards! Hi , I'm new on this forum so don't judge too hard.. But I have a few questions. I am recently new to PHP as this is my first computer language I've learnt besides HTML. My first question is, what's the difference between !== and !=, and is it more secure to use !== when comparing two fields such as passwords? I've different things and this has confused me.. And my second question is, I have this piece of code Code: [Select] /* option error checking */ $field = "option"; // Use field name for option /* Check if the option picked is from the list of options to choose from*/ if($suboption !== "option1" || $suboption !== "option2" || $suboption !== "option3" || $suboption !== "option4" || $suboption !== "option5" || $suboption !== "option6" || $suboption !== "option7"){ $form->setError($field, "* Unexpected error with option"); } I'm guessing in the long run, this will slow down my script.. is there an easier way of checking without using || $suboption !== and is it okay if I've used !==? Like I said I'm new to this so please don't flame.. I've done some research but I can't seem to find some accurate answer. Thank you, ZT What I want to be able to do is this: If I have a list of values in my database: 1 13 26 15 12 4 I do a query of this database and sort it asc so it looks like this: 1 4 12 13 15 26 I want to know how I can use php and/or sql query to find these values based off of "position" in the list. If I wanted the 3rd value in the list, that value would be 12. If i wanted the 2nd value in the list it would be 4. How would I go about doing this? Thank you in advance. I am trying to find a character in the follwing string $string = ' Mumbai Mast Kallander - 02 - Mumbai Mast Kallander'; the character i want to find is '-' and the find how many times does it occur in the string.. can anyone help? Hey guys, Say I have two variables, the first being $level_1 = '100'; and $level_2 = '1000'; is there anyway to work out the difference between the two and output it? Hi I'm very much a newbie to PHP and am struggling with a registration and login problem. The registration part is fine - the password is emailed out fine, I check the database and the entry is there, the password is encrypted. but when the user tries to log in.... if (mysql_num_rows($result) == 0) .... it returns 0? and the access denied page is shown. I'm thinking it is something to do with the sql database encryption? I'm completely lost here and would appreciate some guidance Thanks in advance Jan Good Evening, I've created a function to get the Range of an array (Highest Value - Lowest Value). Now I'm trying to use this to find the Range of the Upper Quartile(Q3) and the Lower Quartile(Q1) but am not sure as to what is the best/most efficient way of doing this? Should I find the middle value of the array, and then create 2 new arrays, the top half and bottom half, then use the Range function on each of them to get Q3 and Q1 or is there a better way to go about doing this? $x = array(); sort($x); // calculate median (middle number/value) $count = count($x); $middleval = floor(($count-1)/2); if($count % 2) { $median = $x[$middleval]; } else { $low = $x[$middleval]; $high = $x[$middleval+1]; $median = (($low+$high)/2); } // calculate range $min = min($x); $max = max($x); return $range = $max - $min; any help/suggestions are appreciated! Thank you. Kind Regards, Ace Good day, Is there a simple way to find and list duplicates i an array and insert these to a new one? I have: $array[0] = "asd" $array[1] = "ter" $array[2] = "asd" $array[3] = "asd" $array[4] = "xfh" From that, I need this: $newarray[0] = "0" $newarray[1] = "2" $newarray[2] = "3" I have poked around "array_not_unique" and "in_array" a bit, but can't wrap my head around it enough for it to work... Any and all help are much appreciated. Thanks in advance! Hi PHPfreaks, I've got a problem Ive been faced with a few days now, and for the life of me Im unable to solve it. What I have is a multidimensional array, that I need to parse and retreive every possible outcome possible Below is a basic example of how the array would look Code: [Select] Colour Black White Blue Finish Matt Gloss What I need to be able to do is, as I said, Show all the possible combinations there is. below is what i'd have achieved after one of you helpful souls points me in the right direction. Code: [Select] --> Color: Black --> Color: White --> Color: Blue --> Finish: Matt --> Finish: Matt --> Color: Black, Finish: Matt --> Color: White, Finish: Matt --> Color: Blue, Finish: Matt --> Color: Black, Finish: Gloss --> Color: White, Finish: Gloss --> Color: Blue, Finish: Gloss As you can see, Only ONE (or no) value is picked from each section. Just to confirm: the number of option groups WILL change...... So I could have colour, finish, size, weight and many more. the number of values in the groups WILL change....... so under colour, I could also have pink, green, indigo, gray. Below is how this array is structured Code: [Select] Array ( [0] => Array ( [parent] => Colour [values] => Array ( [0] => Array ( [name] => Black ) [1] => Array ( [name] => White ) ) ) [1] => Array ( [parent] => Finish [values] => Array ( [0] => Array ( [name] => Matt ) [1] => Array ( [name] => Gloss ) ) ) ) Would anyone have any suggestion on how this can be done? I've pulled out every single strand of hair I've got now, so thought i'd admit defeat and let someone else have a go Many thanks inadvance. Okay, I'm wanting to do a search, but until return the info if it has a specific indicator in the chosen field. Let me show you: $query = doquery("SELECT * FROM `orgs` IF `type`='c' ORDER BY name", "orgs"); How do I do that "IF" bit? Obviously this doesn't work. Thanks! |