PHP - Question Regarding Replacement
I want to duplicate my website but I don't want to have to edit my original files to change like the phone number on the page and upload it to my duplicate site, I just want to either insert coding on my duplicate website that would cause my original website to show up differently, like changing the phone number listed on the page.
Similar TutorialsI am having trouble trying to fix my eregi call in my script. I have a reporting tool that grabs information from the user agent when they email help questions. I used eregi to find the string in an array and print out when it finds a match. I don't fully understand the PCRE functions so i don' t know if i am using them right. what i have is foreach($OSList as $CurrOS=>$Match) { // Find a match if (eregi($Match, $_SERVER['HTTP_USER_AGENT'])) { // We found the correct match break; } } I know i need to change this around for PCRE preg_match maybe but i am not sure. if anyone could send me a tutorial or help me out it would be great. EDIT: notice the foreach was not correct Hello all, I have a script uploading files on the server. I would like to send a confirmation to user if the file had been uploaded well. Code: [Select] $targetFile = str_replace('//','/',$targetPath) . $filename; move_uploaded_file($tempFile,$targetFile); if (str_replace($_SERVER['DOCUMENT_ROOT'],'',$targetFile)) { mail($to, 'upload notification', "Dear Mr/Mrs $fixedname, the file entitled $filename has been successfully uploaded"); }else { mail($to, ' upload notification', "Dear Mr/Mrs $fixedname, the file entitled $filename has been NOT uploaded"); } I presume I do something wrong because it doesn't work. The successfull email is sent each time. Thank you very much for helping, Eric $out = wordwrap($data,400,"@"); $output = explode("@",$out, -1); By default a -1 no longer works properly for me so I need a similar method to get the same output. I made a game back then that reads the php file. So I could change the extension to .php4/.php5 (forget which one would work) the sockets will still link to the default .php file. So how can I fix this? Hi guys, I need to find a way to do the following in this string: Code: [Select] {"id":"51","value":["Lorem Ipsum","Lorem Ipsum","new"]} I need to match Code: [Select] "id":"51" If that is matched, I want to remove that ENTIRE string. How would I go about doing that? In other words, I run a preg_match or something like that and if "id":"51" is found, i need to remove the entire element in which it is contained. In this case the element is the above mentioned string. Any ideas? Perhaps with RegEx? (I have no clue how to use RegEx) My code for replacing user input is as follows: function Replace_BB($text) { $bb = array( '@\[u\](.*?)\[\/u\]@is', '@\[i\](.*?)\[\/i\]@is', '@\[b\](.*?)\[\/b\]@is', '@\[img\](.*?)\[/img\]@is', '@\[url\](.*?)\[/url\]@is', '@\[url=http://(.*?)\](.*?)\[/url\]@is' ); $html = array( '<u>$1</u>', '<em>$1</em>', '<strong>$1</strong>', '<img src="$1" />', '<a href="$1">$1</a>', '<a href="$1">$2</a>' ); return preg_replace($bb, $html, $text); } print_r (Replace_BB($_POST['data'])); How can I use an if statement to decide how to put in my replacement. So for example: Code: [Select] $html = array( 'IF XXXXXX THEN DO THIS>>>>> <u>$1</u> ELSE DO THIS >>>> <u>$1 Error</u>', Hi, I currently have some PHP scripts that verify form data using ereg() as follows: if (ereg(".",$var1)==0) { //do something } where instead of the argument "." I also use "\@" or "\....*", etc. to test whether certain form input is in the correct format (e.g. testing for a valid email address, etc.). However, I have understood that ereg() is being deprecated. What is the best/easiest function to replace ereg() with? Thanks! when in a form, I wish to build a conditional that if the response to a radio button is a value of 2 (female), it will display an input requesting for users maiden name. If not 2 goes to the next input statement. Here is code I was experimenting with: <html> <body> <form action="" name="test" method='POST'> <input type="radio" id="sex" value=1 checked><label>Male</label> <input type="radio" id="sex" value=2><label>Femaleale</label> <?php $result = "value"; if ($result == 2) echo "<input type='int' id='gradYear' size='3' required>"; else echo "Not a female!" ?> <input type="submit" value="GO"> </form> </body> </html> The code passes debug, however, Not a Female is displayed. My question is - Can I do this and if so, what value do I test against id='sex' or value. I tried each one but gave the same results. I realize that $_POST[sex] would be used after the submit button is clicked. But this has me stumped. Thanks for the assis in advance. I am trying to make my database search only search where private = '$priiv'(Usually 0,1, or 2) but it does not work Code: [Select] $query_search = "SELECT * FROM users WHERE username LIKE '%$idea%' OR fname LIKE '%$idea%' OR lname LIKE '%$idea%' OR tags LIKE '%$idea%' AND private = '$priiv'"; What am i doing wrong? Hi to all people, I just want to know if there a php script I can use using DRM. The scenario, once the user download the song from a website, he/she can't forward into other using bluetooth or file transfer. It is possible to do that scenario? Thanks in advance hi, im trying to say if field ARTIST = Eminem then do the following. here is my current code Code: [Select] $hmm = simplexml_load_file('http://localhost/1.0/?method=player.getPlayQueue'); foreach($hmm->tracks->track as $tracks) { $artist = $tracks->artist; $title = $tracks->title; $album = $tracks->album; $index = $tracks->index; $id = $tracks->id; //If we submitted the form if('.$artist.'="eminem") { echo '<table border="0" width="70%" align="center">'; echo '<tr>'; i just need to know how to do the if(***) part. thanks. Hello. I'm trying to pull information out of an xml file. However I'm a bit lost in getting the actual value. Code: [Select] $url="http://ws.audioscrobbler.com/2.0/?method=artist.getimages&artist=Dr%20Feelgood&limit=1&autocorrect=1&api_key=c107c9b5c09cb5693b6c19409dd984c1"; $xml = simpleXML_load_file($url,"SimpleXMLElement",LIBXML_NOCDATA); $largesquare=$xml->images->sizes->size[2]; Is what I have but its not pulling the information. The above url will give you the link to a set xml file for this example. And I want to get the info for the Code: [Select] <size name="largesquare" width="126" height="126">http://userserve-ak.last.fm/serve/126s/43173899.jpg</size> I'm sure I'm doing something wrong that's a simple fix but I am lost here. In the sizes there are 6 different size options each with different names and I have no idea how to pull the one with the correct name that I need. Thank you to who ever can help me sort this out. Just get started with OO in PHP. If I create an object while on one page and then call another page, can I still access that first object, or is it destroyed when the second page is called? For example, if I have on page1.php: Code: [Select] $obj = new $MyObject(); and then call page2.php, is it possible to still access $obj while on that page? I'm considering getting a VPS, but I'm not entirely sure what this would be able the handle. The specs doesn't look that good to me, but my friend swears it will handle running apache/php/mysql handling large websites and databases without a problem. I want to run multiple databases that just store statistics and I'm a bit worried about the RAM and the company doesn't even mention a cpu. Here's the specs: 256MB RAM 300GB HDD 10Mbps unmetered 1 IP Address My friend runs two counter-strike: source servers off his VPS (same stats).. so I'm actually considering this, but it just seems like it's not powerful enough. Oh.. forgot the most important part.. it's only $9. Code: [Select] <?php if ($News_1_Status=="Y") echo <div class="newstitle" align="left"><?php echo $News_1_Date;?> <a href="<?php echo $News_1_URL;?>"><?php echo $News_1_Name;?></a></div><br>; else echo "Have a nice day!"; ?> how do i get the above script working any clue? Hi, I am looking into a way of adding addons to a class I made.. I thought something like this would work, but not sure how to implement it: Code: [Select] <?php class foo { function foobar($text) { $text = $text . 'b'; return $text; } } class bar extends foo { function foobar($text) { $text = $text . 'c'; return $text; } } $var = new bar(); $var->foobar('a'); // this would then return abc ?> Now i want to be able to call up foo, and it calls the foobar of foo, and the foobar of bar. is that possible? hosh hi php people, I am wondering will if the code below will work when I call $C->getafoo() will I get foo; I keep getting an error at this point return $this->A->a(); saying the method is not there Code: [Select] class A{ public function a(){ return "foo"; } } class B { public $A; function __construct($A) { $this->A = $A; } public function geta(){ return $this->A->a(); } } class C extends B{ public function getafoo(){ return geta(); } } $C = new C(new A()); echo $C->getafoo(); I have an issue with the below code Code: [Select] if ($gtype == "%24L" || $gtype == "$L") The value actually starts with the dollar sign then L, but its being read as a variable that's not assigned so it showing as blank. so the question is how to I get to check and see if the value of gtype actually is $L in a way that it wont read $L as a variable and as a value instead? hello all, i am having a for each problem. im trying to get two post fields using the foreach function. here is what i have in my form.php: Code: [Select] <?php foreach($_POST['staff'] as $value) { echo "$value - <br />"; } ?> the name of the the fields coming in are Code: [Select] name='staff[]' and the second one is name='descr[]' fields += 1; |