PHP - Extract Domain From Strings?
Hey
Im trying to extract urls from inputted data so i can seperate it from the rest of the text but can't seem to work out what regex i need to use. The main issue is im trying to extract a specific domain example (google.com) But it could be written 4 ways (google.com, http://google.com, http://www.google.com, www.google.com). Does any one know how you do it ? Similar TutorialsThis topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=321546.0 This topic has been moved to the corner of 3rd Avenue and mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=359430.0 I have two domains both running SSL. Let's call them old-domain and new-domain. old-domain is permanently redirecting traffic to new-domain. There are still a lot of links out there to old-domain with https://. If I were to remove SSL from old-domain but keep SSL on new-domain, I am betting that users will be getting some sort of certificate error. Right? Any way around that if I want to remove SSL from old-domain?
So I have been working on my website for a while which all is php&mysql based, now working on the social networking part building in similar functions like Facebook has. I encountered a difficulty with getting information back from a link. I've checked several sources how it is possible, with title 'Facebook Like URL data Extract Using jQuery PHP and Ajax' was the most popular answer, I get the scripts but all of these scripts work with html links only. My site all with php extensions and copy&paste my site links into these demos do not return anything . I checked the code and all of them using file_get_contents(), parsing through the html file so if i pass 'filename.php' it returns nothing supposing that php has not processed yet and the function gets the content of the php script with no data of course. So my question is that how it is possible to extract data from a link with php extension (on Facebook it works) or how to get php file executed for file_get_contents() to get back the html?
here is the link with code&demo iamusing: http://www.sanwebe.c...-php-and-jquery
thanks in advance.
Not sure if there is a better way to do this, but I want to check whether the value in a Sticky Field is the same as what is in the Database. If what is in the Sticky Field is *exactly* what is in the Database, then the User didn't update that field, and so I would NOT do an UPDATE. Seem reasonable? Here is where I grab the value out of the Form... Code: [Select] // **************************** // Process Each Form Field. * // **************************** foreach($_POST['answerArray'] as $questionID => $response){ // Copy trimmed Form array to PHP array. $answerArray[$questionID] = trim($response); And here is where I grab the existing value in the Database... Code: [Select] // ******************** // Check for Answer. * // ******************** // Build query. $q1 = "SELECT response FROM bio_answer WHERE member_id=? AND question_id=?"; // Prepare statement. $stmt1 = mysqli_prepare($dbc, $q1); // Bind variable to query. mysqli_stmt_bind_param($stmt1, 'ii', $memberID, $questionID); // Execute query. mysqli_stmt_execute($stmt1); // Store results. mysqli_stmt_store_result($stmt1); // Check # of Records Returned. if (mysqli_stmt_num_rows($stmt1)==1){ // Answer Found. // Bind result-set to variable. mysqli_stmt_bind_result($stmt1, $currResponse); // Fetch record. mysqli_stmt_fetch($stmt1); So I guess I want to compare $answerArray[$questionID] against $currResponse and see if there are any differences?! What is the best way to do that? Any better ideas of how to check to see if the User made any changes to a field so I only do an UPDATE if there was actually a change? Thanks, Debbie hello, here is what i have, obviosly it doesnt work. Code: [Select] $year=$_POST['y']; $yr=substr($year,-2); $mth=$_POST['m']; $init=$_POST['initial']; $jobnumber=$yr$mth2343$init; echo "$jobnumber"; P.S. thanks to everybody for their help lately! How can i break down strings for example i have a simple search database for products where as a user searches a term this can be one, two three words and so on. I'm using a wildcard; but i want the best way to get the possible search so i would like to break down the string into separate words and then use that to search the database using wildcards is this possible? Thanks for reading. Hey guys!! So basically what I am doing here is pulling the directory out of a url. URL ex: http://www.xxx.com/T...IS_WHAT_I_WANT/ Hello, I was wondering if someone could help me to "get" the webaddress of a current webpage and then pull off pieces of the page. All of my pages look like: http://localhost:8888/algebra_book/Chapters/Quadratic_Functions/introductory_problem.php BUT, the stuff to the left of Quadratic Functions WILL change in the future. So all will look like: *Quadratic_Functions/introductory_problem.php Then, I'd like to pull off a $chapter variable, which in this case is Quadratic_Functions and a $page_name variable which in this case will be introductory_problem. Thanks so much. I was thinking how can I make a script that will build strings incrementing through each letter starting with "a" and ending with "zzzzzz" or what ever ending length I want such as 12. So if your were to output everything, you could find the words: "dog" "spider" "superman" "hippo" etc What would be the best way to do this, so I don't have to have a loop that is 500 blocks deep to show a word that is 500 letters example Quote a ... z aa ab ac ... az ba bb bc ... ... aaa aab aac is there a way I can make something like a ticket in pdf format that can have $name or the likes echo in it? if you could help get me started, that would be great! Hi I am having troubles using a string in a cookie.. This doesnt work: setcookie("background", "$image_name", $expire, "/", ".gedoo.com"); Neither does this: setcookie("background", "" . $image_name . "", $expire, "/", ".gedoo.com"); If I write something before $image_name like: setcookie("background", "hello" . $image_name . "", $expire, "/", ".gedoo.com"); It will save "hello" in the cookie.. So in other words, $image_name doesnt look like it is defined.. But the funny thing is that this works on the same page: echo "File Uploaded Successfully!<br><img src='images/$image_name'>"; Anyone have any idea on what I am doing wrong? So I make a colum in my table called "friends" Is there a way to update using mysql that colum for each user, so let's say friend 1 adds friends 2 with the id of 25 so the query puts the id "25" into the friends column, then if friend 1 adds friend 5 with the id of 26 it puts "26" into the friends column and so on... So it would have like commas in the colum, 25,26,30,31,31 and all those represent the id's of the person who is wanting to add people to his friends list! If so how do I accomplish that, and then what If I want to use mysql to list all those id's and Code: [Select] SELECT name,avatar,etc from userstable WHERE id = "25,26,3,31,31" Is this even possible or am i thinking to harD? or need to extract all h1 tags and insert into database You can modify this code to make it work? ////////////////////////////////////////////////////////////////// function getTextBetweenTags($tag, $get, $strict=0) { /*** a new dom object ***/ $dom = new domDocument; /*** load the html into the object ***/ if($strict==1) { $dom->loadXML($get); } else { $dom->loadHTML($get); } /*** discard white space ***/ $dom->preserveWhiteSpace = false; /*** the tag by its tag name ***/ $content = $dom->getElementsByTagname($tag); /*** the array to return ***/ $out = array(); foreach ($content as $item) { /*** add node value to the out array ***/ $out[] = $item->nodeValue; } /*** return the results ***/ return $out; } $content = getTextBetweenTags('h1', $get); foreach( $content as $item ) { $h1 = $item.'<br />'; } $query="UPDATE sitis SET hh = '$h1' WHERE id = '$a'"; //My problem and that puts only a h1 regards Folks, from the below code, i want to extract value of the [template_path] in a Variable. The value that i want to extract is " /home/ae1df/public_html/master/proae2/gdfcart/templates/default-black/". I tired to do $this->template_path but seems not working, Can anyone help please? Here is the Code >>> Savant3_Error: Array ( [code] => ERR_TEMPLATE [info] => Array ( [template] => sidebar-left.tpl ) [level] => 256 [trace] => Array ( [0] => Array ( [file] => /home/ae1df/public_html/master/proae2/gdfcart/includes/template.php [line] => 1298 [function] => __construct [class] => Savant3_Error [object] => Savant3_Error Object ( [code] => ERR_TEMPLATE [info] => Array ( [template] => sidebar-left.tpl ) [level] => 256 [trace] => Array *RECURSION* ) [type] => -> [args] => Array ( [0] => Array ( [code] => ERR_TEMPLATE [info] => Array ( [template] => sidebar-left.tpl ) [level] => 256 [trace] => 1 ) ) ) [1] => Array ( [file] => /home/ae1df/public_html/master/proae2/gdfcart/includes/template.php [line] => 1121 [function] => error [class] => Savant3 [object] => Savant3 Object ( [__config:protected] => Array ( [b][template_path] => Array ( [0] => /home/ae1df/public_html/master/proae2/gdfcart/templates/default-black/ [/b][1] => ./ ) [resource_path] => Array ( [0] => /home/ae1df/public_html/master/proae2/gdfcart/includes/tmpl/resources/ ) [error_text] => template error, examine fetch() result [exceptions] => [autoload] => [compiler] => [filters] => Array ( ) [plugins] => Array ( ) [template] => [plugin_conf] => Array ( ) [extract] => [fetch] => /home/ae1df/public_html/master/proae2/gdfcart/templates/default-black/error.tpl [escape] => Array ( [0] => htmlspecialchars ) ) [banner] => stdClass Object ( [header] => stdClass Object ( [banner] => [count] => 0 ) [left_box] => stdClass Object ( [banner] => [count] => 0 ) [right_box] => stdClass Object ( [banner] => [count] => 0 ) [hometop] => stdClass Object ( [banner] => [count] => 0 ) [homebottom] => stdClass Object ( [banner] => [count] => 0 ) ) [template] => default-black [site] => stdClass Object ( [name] => Paintball Mall [slogan] => This is Master Installation [url] => http://gdfcartophily.co.uk/ [disclaimer] => CERTAIN CONTENT THAT APPEARS ON THIS SITE COMES FROM AMAZON EU SARL. THIS CONTENT IS PROVIDED "AS IS" AND IS SUBJECT TO CHANGE OR REMOVAL AT ANY() Many Thanks [/code] Good day all.
I am trying to get strings from txt file with a start and an end.
$file = "/var/www/html/sataxicrm/custom/include/language/lang.en_us.lists.php"; $content = file_get_contents($file); $pos = strpos($content,"query_complaint_type_list"); $end = strpos($content,"status_0"); $string = substr($content,$pos,($end- $pos)); $array = nl2br($string); //print $content; echo "Database Value:Label Value <br>"; print $array;
The above code works well if you knowwhat your end string is, but in my case i do not know. i only know the start. As you can see i know it starts with account_type_dom but i do not know that it will end before industry_dom. so i need to stop before industry_dom. how do i do this? Quote
account_type_dom
Hello guys, need some help. Let us say i have an array = 2011 ipad 2011 ipad review 2011 ipad price 2011 ipad design 2011 ipad reviews review 2011 ipad 2011 ipad feature I would like to review all the array elements that contain "review"...So the final array should look like 2011 ipad 2011 ipad price 2011 ipad design 2011 ipad feature Thanks I have a php page which is ran after a form is posted from the previous page. I am having trouble getting the SQL strings to work. When the page is ran online there is no WSOD or error message but the tables in my database are not being updated. Any help with this would be greatly appreciated.
Attached Files
payment.php 1.79KB
4 downloads This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=316055.0 |