-
Posts
168 -
Joined
-
Last visited
Never
Contact Methods
-
Website URL
http://www.inspiredideasltd.com
Profile Information
-
Gender
Male
-
Location
Bulgaria
jwhite68's Achievements
Regular Member (3/5)
0
Reputation
-
How to use preg_replace to replace a particular string
jwhite68 replied to jwhite68's topic in PHP Coding Help
Yes, its possible that the action= could be a different action. eg. action=signup (and a bunch of others) for which I dont want to remove the cmsrealty=admin. So, its specifically on the occurence of cmsrealty=admin, for action=listingview, when a listingID is provided. Hope that makes it clearer. Thats why I cant get my head around it! -
How to use preg_replace to replace a particular string
jwhite68 replied to jwhite68's topic in PHP Coding Help
When I ran the script, it removed the action= though... <?php $str = "action=listingview&listingID=142&cmsrealty=admin"; parse_str($str,$pieces); if(array_key_exists('cmsrealty',$pieces){ unset($pieces['cmsrealty']); } $str = implode('&',$pieces); ?> The actual 'problem' I probably havent explained clearly enough. I first have to locate the occurence of a string like $str in a larger string. Where the ID=xxx number part is different. How can I use PHP functions to locate this pattern, and then replace that pattern by removing the &cmsrealty=admin? -
How to use preg_replace to replace a particular string
jwhite68 replied to jwhite68's topic in PHP Coding Help
Doesnt the above still assume that the ID=142 is fixed though? Since this is variable, I need to just assume that what comes after ID= is a number. -
How to use preg_replace to replace a particular string
jwhite68 replied to jwhite68's topic in PHP Coding Help
Cant assume its the last part of the string. Its part of some processing that renames URL's thats part of the system I am using. I need to make sure that when I find this particular string, the replacement is only applied to this string and not others. In your example, $str is actually the search string. This appears in a larger string called $page. When I find $str, I need to strip out the &cmsrealty=admin. -
I have a string, which is of this format: action=listingview&listingID=142&cmsrealty=admin The ID number, 142 in the example, is variable though. How do I strip the '&cmsrealty=admin' from the above string? Assumed I could use preg_replace but cant understand how to use it for above scenario.
-
I wanted to add that after the code in the logout section, there is the following: session_destroy(); session_unset(); session_write_close(); header("Location: ".$domain."index.php"); exit(); I have read that the redirect could be causing a problem. ie it redirects to the index.php page before it can complete the deletion of the cookies?
-
I have a fairly simple code segment inside a login script which both sets the cookies and "attempts" to delete them on logout. if ($act=="login"){ if (!isset($_COOKIE['cookname']) && !isset($_COOKIE['cookpass'])){ setcookie("cookname", $_SESSION['UserEmail'], time()+60*60*24*100, "/",".domain.com"); setcookie("cookpass", $mdpass, time()+60*60*24*100, "/",".domain.com"); } } f($act=="logout") { if(isset($_COOKIE['cookname']) && isset($_COOKIE['cookpass'])){ setcookie("cookname", "", time()-60*60*24*100,"/",".domain.com"); setcookie("cookpass", "", time()-60*60*24*100,"/",".domain.com"); unset($_COOKIE['cookname']); unset($_COOKIE['cookpass']); } exit(); } Note: This is an abridged login script, showing the relevant parts for cookie handling. When testing, I can see that the cookie is getting set. When I logout though, and then go back to a page that checks the cookie variables - it shows that they are set, even though the code to delete the cookies has been executed. Having read many topics on several forums, the issue seems to relate to the addition of the domain name as the last parameter, but even with this, its not working. Have tested on both IE and Firefox with the same result. Does anyone have any suggestions? Jon
-
Suggestions on news agrgregator scripts for news feeds
jwhite68 replied to jwhite68's topic in Third Party Scripts
Thanks for that. I'll give it a try and see how I get on. Jon -
I am looking for a third party script that can allow me to pull in multiple RSS feeds, and display news headlines on my website. It can link to the main story on the news "owners" site. I came across zfeeder which appears to do the job, but wondered if anyone out there has any comments/feedback on this zfeeder, or can offer any other suggestions that I could look into. Thanks, jon
-
Does anyone know if: (a) Its possible to convert an XML file to Excel (xls file) with PHP, (b) If so, whether this is a script available as either free/shareware or commercial for this purpose? Thanks. J.
-
How to display text dynamically on HTML depending on radio button
jwhite68 replied to jwhite68's topic in PHP Coding Help
Can you advise code-wise on the PHP route? I would just like to understand how I code the radio buttons as submit inputs. Thanks. -
How to display text dynamically on HTML depending on radio button
jwhite68 replied to jwhite68's topic in PHP Coding Help
Any tips on how to achieve this in the code? -
I have a HTML form (combined with PHP script) which presents 3 radio buttons. When either of the first 2 radio buttons are selected, I want to display a piece of text on the form - eg. Amount : $100. If the user selects the third radio button, I dont want to display this text. How can I achieve this? <td width="217"><input type="radio" id="type" name="type" checked="checked" value="single" style="width:15px"> Option 1</td> <td> <input type="radio" id="type" name="type" value="multiples" style="width:15px"> Option 2 </td> <td width="136"><input type="radio" id="type" name="type" value="multiples" style="width:15px"> Option3</td>' </tr> </table> <div> Select option <? if (<what do I put here?> { ?> Amount: $100 ?> <? } ?> You see that I want to display the text Amount: $100, if the condition shown by <what do I put here> is true. Can anyone advise. So, on selection of the first or second radio button, I want to display the Amount, but if the third radio button is selected I dont want to display Amount text.
-
My existing code has the following function, which uses some form of 'convert' function to create a thumbnail file. However, its not working on the web server - even though it used to. I have inherited this code, and do not know the background behind it. Does anyone recognise it, or know what this 'convert' function is? See 'this line' marker below. I cannot see any PHP function called convert, and assume its some library that needs to be compiled into PHP, or maybe referencing a PERL function? function resizeByWidth($input,$output,$width,$onlyIfBigger=true){ /* Description : Resizes regular image by given height Parameters : input : path to the file output :path to output file height :the new height onlyIfBigge : wheather to resize if image height is smaller then new height Returns : true : if success false : if file not exists or not a regular image */ if($pic_info = checkImage($input)){ if($pic_info[1]<$width && $onlyIfBigger){ copy($input,$output); echo'File copy'; return false; } $proportions = $width/$pic_info[1]; $newHeight = round($pic_info[2] * $proportions); $cmd = 'convert '.$input.' -thumbnail '.$width.'x'.$newHeight.' '.$output; <--- this line $res = `$cmd`; echo $res; } else{ return false; } }
-
Thanks. So simple, when you know how!