Breaking Backwards Compatibility - Good Or Bad?
If you have any PHP scripts which will not work in the current releases
due to breaks in backwards compatibility then take a look at
http://www.tonymarston.net/php-mysq...everything.html and see if
you agree with my opinion or not.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Parsing Backwards
I have a database with a lot of names and some of them are german or french or any other language that has special characters. let's say we want to add "Jádson" to the database. when added,in the database I find "Jádson" instead of "Jádson". It is quite OK because when I try to echo each field, in any browser, I see "Jádson" not "Jádson",and this is what I want. The problem is when I try to search something in the database. If I make a link,something like www.site.com/$name and each time $name changes,when I get to "Jádson" it dosen't find any entry in the database with that name, because in the database it is actually "Jádson", so I can't use any information for this guy. I guess everyone sees my problem. I need 2 things. 1 - First of all I need a way, an algorithm to parse back from "Jádson" to "Jádson", that workes for any kind of characters,not just this. For example, if I input in a field "Jádson" I should get back this string -> "Jádson". 2 - Secondly, I need a way, an algorithm that can change any name like "Jádson" or "Jérémy" or "Tomić" to "Jadson" and "Jeremy" or "Tomic" .
Backwards Substr()?
I was wondering if there is a function that does the same thing as substr but starts from the end so when i did substr($string, 0, 4) i would get the last four characters of the string. I know i can do the following to get the last four characters: <?php $last_character = (strlen($string) - 1); $first_character = ($last_character - 4); $sub_string = substr($string, $first_character, $last_character);?> However if there is something that already does this i rather use that, if not i will just build this function into my file that has all my common functions.
Incrementing Backwards Through An Array
I am trying to increment backwards through an array but having some problems. I will post the arrays that I am using to trouble shoot as these are not the arrays that I will be actually using. Code:
Sorting Alphabetically Backwards Lists
This code runs @ http://www.ckoogle.com but the trouble is once I get the list backwards, and in an array. I can't sort the new array into alphabetical order. Anyone know a way to do it? <?php echo '<form action="index.php" method="post">' echo '<textarea name="input" cols="12" rows="20">' echo '</textarea><br>' echo '<input type="submit" value="Submit">' echo '</form>' if( isset( $_POST["input"] )){ $my_array = $_POST["input"]; $my_array=strrev($my_array); $my_array=explode(" ", $my_array); print_r($my_array); sort($my_array); print_r($my_array); for($cnt=0; $cnt < count($my_array); $cnt++) { echo(strrev($my_array[$cnt])); echo('<br>'); } } ?>
Srv OS Compatibility And $_ENV
I'm running PHP on my local WinXP box, but will host on *nix Srv. So I started to use and OS detect, something like (psuedo-code): if ( strpos($_ENV['OS'], "Win") === false ) { *nix } else { Win } but its not working right, and I wondered why. My OS looks to be set, as shown by WinXPset ditto for output from phpinfo() But the $_ENV global, looks like an empty array Array ( ) whats the story ? Of course I've the incompatible versions of Apache/PHP: A2.2x and php5.1.x patched with php5apache2_2.dll ( thats the only reason I didn't cry after installing 5.1.4 and then having 5.1.5 come out the next day ) It makes you wonder, what part of 5.1.x am I really using, if any my settings from phpinfo(): Apache Version Apache/2.2.3 (Win32) PHP/5.2.0RC2-dev
$_SESSION Compatibility
does anyone have any stats on the percentage of browsers/environments that support session cookies? Reason I ask is that I might have come up with a spellbinding anti-form-spam solution.
Browser Compatibility
I'm making a site where people can make posts which are then rated 1-5. I want to write a php code that takes the rating and displays a corresponding image. I have written this: function ratingImage($overallrating) { if ($overallrating == 0){ echo "<img src="images atingzero.jpg">"; } elseif ($overallrating == 1){ echo "<img src="images atingone.jpg">"; } elseif ($overallrating == 2){ echo "<img src="images atingtwo.jpg">"; } elseif ($overallrating == 3){ echo "<img src="images atingthree.jpg">"; } elseif ($overallrating == 4){ echo "<img src="images atingfour.jpg">"; } elseif ($overallrating == 5){ echo "<img src="images atingfive.jpg">"; }} echo ratingImage($overallrating); This codes works perfectly in safari, but when I view the page in firefox or netscape navigator, the images do not appear. Can anyone think of why this code would not work in these two browsers?
Cookies & Browser Compatibility
I'm trying to set a cookies in both the secure and non-secure portions of my site. For example: setcookie("id", $id, $cookielife, "/", "http://www.mysite.com", 0); setcookie("id", $id, $cookielife, "/", "http://secure.mysite.com", 1); IE5.0 won't work with anything after $id. NN4.7 seems to work OK (I think). Is there a compatibility usage list anywhere which shows how to set cookies for each browser/version?
Best Way To Deal With Javascript (in) Compatibility Using PHP?
We have started off using a $_GET parameter to keep track of the user's browser: We detect what browser the visitor is using when he first arrives on our website then we do a redirect to the same page adding on "&browser=IE" or "&browser=DOM" at the end of the url (and we keep the browser parameter in the URL the whole time he is on the website), this enables us to use the following PHP method: function javascript($name) { if($_GET[brow] == "IE") { return "document.all('$name')"; } else { return "document.getElementById('$name')"; } } That we use like this (for example here we are setting the inner HTML for the item whose ID is 'contribute'): <?=javascript('contribute')?>.innerHTML = "Name"; Everything was working fine but we have realised that the Googlebot cannot deal with $_GET parameters so we are looking into url rewriting but it is going to be very complicated to keep the method we are using with url rewriting. We would be interested in hearing about the way people deal with javascript browser compatibility using PHP. There must be some much simpler ways of doing this but we are not sure how to do it. Any input would be helpful.
Testing PHP4 Compatibility
I am a new php coder, learning php5. If I am trying to make a website on a server that supports only php4, is there a good reference to use to test if the code I am making is backwards compatible? or is php very BC friendly?
Functions' Compatibility For UTF-8 Encoding
I'm writing a system with PHP which encodes with UTF-8 encoding. Everything is encoded with UTF-8 encoding. In order to work with UTF-8 encoded strings, I need to use special functions - mbString function (stands for Multi Byte String), that specially compatible for UTF-8 encoding and others. The problem is that there aren't enough mbString functions so that I will be able to work well with UTF-8 encoded strings. Many important mbString functions are missing. I wrote a list of regular functions and I need to know if they can work well & suitable for UTF-8 encoded strings. Code:
Compatibility Issues With NUSOAP & PEARSOAP
Scenario is my server is in NUSoap ... and have used complex types in my WS. My client is Pear Soap and GSoap. NuSoap ws accepts an argument with array of complex types, so when i call it from any client (pear/G) it passes last argument as ...
PHP5 And PHP4 Compatibility Issues
adactio.com/journal/1202 has a very interesting PHP script which gathers RSS data from various feeds and prints them in an HTML table. He calls this a lifestream. Anyways, unfortunately, my knowledge of PHP is rather limited - I'd rather work with a stylesheet. It turns out that my local machine has PHP5, and the script works flawlessly. However, Bluehost, my hosting provider, has PHP 4.4.4. As a result, I'm getting a lot of exceptions thrown around. I think I figured out my way around the getElementsByTagName(), which should be get_elements_by_tagname() in PHP4, but I'm still getting heavy exceptions. I also googled and found that the date_default_timezone_set() function isn't supported in PHP4 either. I'd appreciate it greatly if anyone could point out where the incompatibilities are - even if there's a better way of doing this RSS gathering, I'd just like to see anyway for educational purposes. My PHP source is the following (I've left out the HTML surrounding it): <?php date_default_timezone_set("Europe/Paris"); $feeds = array( "feed1" ="http://...", "feed2" ="http://...", "feed3" ="http://...", "feed4" ="http://..." ); $details = array("title","link"); $list = array(); $rss = new DOMDocument(); foreach ($feeds as $name =$feed) { $rss -load($feed); $items = $rss -getElementsByTagName("item"); foreach ($items as $item) { if ($item -getElementsByTagName("pubDate") -item(0)) { $date = $item -getElementsByTagName("pubDate") -> item(0) -nodeValue; } else { $date = $item -getElementsByTagName("date") -item(0) - Quote:
Unix And Windows Php Script Compatibility
I'm a php novice and am developing a shopping cart application for a client who is hosted on a unix server. The hosting service requires that each php file have #!/usr/local/bin/php at the top. When I test these pages on my developer Windows php installation I get errors because Windows does not recognize the bang command so it is passed on as content to the php server. Any suggestions on hiding the first line from windows while still having unix see this?
UNIX/Windows Text File Compatibility
I guess it's a bit off topic but my script is written in PHP so I guess somebody out there could help me. I'm facing the well known issue between windows and UNIX related OS. The file format is crucial. The file is made on a linux box and as to be parsed on a windows box by a commercial software (so I cannot play with the code on that side). I'm having a problem to mark the end of lines. " " as you all know doesn't pass well on Windows. How could I replace this one: fwrite($fichier, "this is a new line "); to make it works with windows?
Breaking Strings?
I have a string (actually 100's of these, but lets take one): $string ="TI: Some journal title AU: SomeAuthor,-S; Smith,-A; Jones,-B SO: SomeSource. 2002 Jan 9; 287(2): 188; discussion 189-90 JN: Some Journal Title"; This needs to be turned into an array: $entry = array( 'Some Item Title', 'SomeAuthor,-S; Smith,-A; Jones,-B', 'SomeSource. 2002 Jan 9; 287(2): 188; discussion 189-90', 'Some Journal Title'); As you can see, each array item should be defined by what comes after either/all of the following: 'TI:' 'AU:' 'SO:' 'JN:' So, I need to be able to create a pattern that can look through the string and return everything in between TI: and AU:, then AU: and SO, etc. for example: eregi(???, $string, $entry); I'm fairly new to this and can't seem to figure out the regex I need for the pattern. Is this even the way to go about it?
Breaking Out Of An Iframe
I cannot figure this one out. My script is being displayed in an iframe (a wiki page) and I have one option won't give me the correct results unless the page is displayed in either a) new tab in NS browser b) new browser instance. The option in question is used to print forms, and I use the browser Print Preview for the page setup. It's all pretty useless if I have the page and iframe content in my preview. I thought using header() would do the trick.
Breaking A Page Down.
What is the best solution to break down a php page into certain section using MySql, For example i'm looking at designing a page that reffers to a MySQL database that contains the html code for the navigation. So that in future if the navigation changes I'll only need to changed the html code in the database and all the pages will be sorted. I'm also looking at doing the same for the information on the footer of the page, with teh contact details.
Breaking Out Of Quotes
I know I can use stuff like in front of " so that it can't break out of a "" and start doing bad things, but it seems there are other situations where, E.G., if the string is hex for " then it has the same effect, and stuff like that, and it gets tricky escaping it all, so I'm wandering, is there some kind of option I can enable or extension I can install that just simply prevents objects/variables/arrays from breaking out of single/double quotes and also for mysql queries? And also for html so E.G. echo"<img src='$asdf'>"; can't be exploited to do other things? I don't care if it isn't free as long as it works good and isn't to expensive..
Breaking Up Querys
I have a page that updates a table every workday. (these are standard updates, like if someone has moved, or has a different phone number or something.) It is too big of a query to run the entire table all at once, so it is split out. The split is grouped by the first letter of a first name field. Right now it is broken up into 5 parts, and each part has a group of letters (i.e. "a" to "d" is one group, "e" to "k" is the next, and so on. As you can see, these do not have an even number of letters, but that is because some letters have a lot more entries, and need to be in smaller groups.) The reason it is split out into 5 groups is that I can run one group on each workday (Monday through Friday), and I can have the PHP check what day of the week it is. (I use a case statement, the first case is for Monday, the second is for Tuesday, etc.) Code:
Breaking A Loop.
I have one going through rows of a sql database until it matches some data with user input. I need to put a break command in there but can't seem to find out how to achieve this.
Breaking Rows
I am using a while statement to pull results from my database. Now if I have like 40 results how would I make it break into rows. So instead of; result result result result result result result result result result result result result result result result result result I want; result result result result result result result result result result result result result result result result result result result result
XML Parser Breaking Up URLs
I'm having a problem parsing an xml file in which one of an elements character data is a url which contains multiple "&" characters. For some reason the parser breaks up the data into multiple pieces. For instance, when I call this function(abbreviated): function characterDataHandler ($parser, $data) { global $element; global $url; if ($element == "URL") { $url = $data; echo "url=".$url."<br>"; } } I get some output like this: url=http://www.somewebsite.com/index.jsp?s=af url=& url=filter=1 url=& url=show=all Do urls with querystrings have to be handled differently then regular character data?
For Loops Breaking At A Certain Multiple
Can someone help me out with writing a script that will make will loop 500 times, but at every 4th multiple, it will insert a peice of code? I tried all day to get this, and so far, nothing has worked.
Characters Breaking My Query
Im using encrypted data to store cc info. The PHP code encrypts and sends the result to the database. the problem is that the encrypted string contains lots of characters that will break my sql query. I can do a replace but there are lots of characters. for example, a character will look like this: g%$^'GDF$%^//"@#$%/||''$#"/|#dfsa. how can I put this information in a different format... and then retrieve the data to decrypt the string?
Not Breaking Loop In Function
I get this error: <b>Fatal error</b>: Cannot break/continue 1 levels in <b>file.php</b> on line <b>128</b><br> This happens when I call a function. In the function there is a break; This is cause the break is in a function and not in the loop. But it gets called inside the loop. Is there a fix for this?
E-Mail Not Breaking Lines
I'm sending an e-mail via a contact form, but somehow the lines aren't breaking in the text, it always looks like this: lorem ipsum dolor sit amet lorem Which is of course not readable at all. What am I doing wrong here? I'm using a few security checks and such for cleaning the field up; $text = trim($text); ... $text = stripslashes(strip_tags($text)); ... $text = mysql_real_escape_string($text); ..... #and then the part where it's included in the message: $message .= "Nachricht: {$text} "; Can any of those be causing the display problem?
Script Breaking On Mysql_result
I was trying to figure out why one of my scripts was failing and by using an "or die" statement for the SQL narrowed it down to this bit of code: $md5 = md5_file("swf/" . basename($jpg_link)); $dupe = mysql_result(mysql_query("select count(gId) from games where gSwfFile='$md5.swf"), 0); if(!empty($dupe)) { continue; } This is giving the following error - "Warning: mysql_result(): supplied argument is not a valid MySQL result resource" The thing is, I've checked that SQL query by running other values in place of $md5 through it and it appears to be fine. select count(gId) from games where gSwfFile='Flat War july 30th 2007.swf'; Any ideas?
Breaking Survey Into Seperate Parts?
I have a very long survey form with 4 different sections. Is there anyway with php to split this form into 4 popup windows so the person can click on the section they wish to fill out and when they are done, go back to the host survey form and continue on? I know there must be a way to do it, i'm just at a loss as to how i would pass the variables off? Cookies perhaps?
Breaking Up A Comma Seperated List
i have a list seperated by commas: 1. 3. 5. 7. 9 actually is a varible $members ="1, 3, 5, 7, 9"; what would be the best way to break that up to insert the values into a table in a loop.
Breaking Up Text For Multiple Pages
I was recently put in charge of heading up my company's website, and while I have a lot of experience on the design side of things, I'm still very new to the programming side. When I started, the website had just gotten a revision, but the site was an utter mess, so I've been trying to fix it up. As I've gone along, I've learned some aspects of PHP, but my knowledge is still very limited. Here is the problem I'm trying to fix. A backend is used to enter information into our MySQL database, and then a page template pulls it out to make the page. For our reviews, the PHP coding currently breaks up the review's text so that it can be places across multiple pages. The problem is, the way the text breaking was set up, the end of one page and the beginning of the next are totally chaotic, with breaks often coming mid-sentence. Here is what I'd love: other coding automatically puts an HTML break at the end of paragraphs, and then another in the space between one paragraph and the next. I'd love to have the code search for when those double breaks come up, and then break up the text after, say, every sixth pair of HTML breaks. I'd also like the option to break the text myself by putting in some sort of text code in the original text. At this point, though, anything that can make the breaks more elegant would be a huge improvement. I really appreciate any help anybody can give me in this one. Please remember that I know very little of PHP, and I'm not much of a programmer anyhow, so things that you may take for granted that people would understand about PHP, I might not know. I tried to pull out what I thought was the current coding for the text break. Here it is. I'd also like to get rid of the part1/part2 factor. Before, they had the text breaking to help in fitting into the layout around an image, but I've fixed that so I no longer need the break. So, that portion no longer needs to be a factor. if ($page == ""){ $page = 1; } $no_letters = strlen($Game_Full_Story); $times = ($no_letters / 3800) +1; $Game_Full_Story = wordwrap($Game_Full_Story,3800,"*#^"); $Game_Full_Story = explode ("*#^", $Game_Full_Story); $pages = array(); for ($i=0; $i<$times ; $i++){ $part[$i] = $Game_Full_Story[$i]; if ($i != 0){ array_push($pages, $i); } } $page = $page-1; $story = $part[$page]; if (strlen($story) < 460){ $parts1 = $story; }else{ $story = wordwrap($story,460,"*#^"); $story = explode ("*#^", $story); $parts1 = $story[0]; $count = count($story); $parts2=""; for ($i=1; $i<$count; $i++){ $parts2 .=$story[$i]; $parts2 .=" "; } }
Breaking Up A String Into Individual Words
I have a text box that I will use to search a database. I would like to use it so that it will not use a whole string (ie. 'red striped top') but instead break it up into individual words (ie. 'red', 'striped', 'top') and maybe put it into and array. I will then use the words in the array to search the database. How do I break a string up this way? Also, is this the most common way of creating a means of searching a database?
Breaking Up The Query String Dynamicly?
using $Get_string = $_SERVER['QUERY_STRING']; to receive a query string such as month=may&$day=15&year=2006 so that $Get_string = "month=may&$day=15&year=2006" can I separate the values and turn them into variables? (like a normally would with a url get) $month = "may" $day= "15" etc it would be great to just do $_GET on the url but I'm sending the string as a variable to another script... so i can't just go the easy route.
Breaking The BACK Button (Refresh Problem)
I have a php page which serves up multiple pages based on how the user interacts with it - there are links on the first page that will reload (from the same php file) a new page with form fields and submit buttons, and when a user posts from that new page (or cancels), then the same php file is again loaded, detecting how the user responded and generating the appropriate html for whatever should be none next. All very typical. What I want to know is, is there a way so that once a user has posted from some submit button from one page (we'll say he Cancel's from a page that had a form Cancel button so he returns to the original non-form default page generated from the php file), can it be made so if the user then "refreshes" the new page (hits the Refresh or Reload browser button) he does NOT get the browser's "The page cannot be refreshed without resending the information. Click Retry to send the information again, or click Cancel to return to the page that you were trying to view." dialog? In other words, what I'd like is a way to have the browser think that there was no posting done (even though there was) once I've generated this certain 'home' page with my php code, so that user ReLoad's of the page won't get this warning. This is probably related also to problems I've had with "breaking the BACK button" on sequences of php pages: if the user BACK's up to a page that was generated by a post, it may not even be possible to regenerate the original page.
Return Data Breaking Input Field
My return data is: (I have nothing to do with how the og person choose to input this) <font color="#800080">CASE</font> and I am setting the value of a input text form field equal to that return $input = "<input type="text" name="queOpt". $i ."" value="". $this->_queArr[$i] ."" />"; im lost on how to fix this. addslashes doesnt make sense - maybe it is the double quote thing
Reading Files Line By Line Backwards
I'm new to PHP, and I'm trying to write something for my website. I have coded a game together with a friend of mine, and as with all new games and programs, it's full of bugs. What I would like to do, is write a page where everyone can post bugs (I have this part, not that hard). Then it should be read from the textfile they're all in, but backwards, so the newest bugs at the top of the list. Also I would like to add an option for me to login using a username and password, to mark bugs as fixed, or delete certain bugs from the list. I have the user part covered too, but I don't know how to delete a single line in the textfile.
A Good OOP Pattern?
I am not new to OOP but would like to make the whole site 100% object oriented. Can anybody suggest/provide a small application or framework (not a big one) so that one can understand the concept of making a whole application in OOP way.
Good Editor?
I wonder if anyone can recommend a good text editor to use for writing PHP? I see lots of scripts about which use colours etc, which makes life a lot easier!
Undefined: Good Or Bad?
I decided to run some code with errors set to E_ALL, just to see what I would run across. It caught a few things, but 90% or better of the messages were of the 'undefined' kind: PHP Notice: Undefined variable PHP Notice: Undefined index PHP Notice: Undefined property I'd like to go back and fix what I can, but I'm wondering: how good or bad is this? I mean, I rely on the fact that the first use of a variable defines it. However, I'm also very used to "use strict" in perl, so I know that on-the-fly variable declarations can be dangerous. Is there a general rule of thumb for correcting these? Best practice? Do most people not care? If it ain't broke don't fix it?
A Good Pic Of The Day Script
Anyone know of a good POTD script I can use. Some of the ones I've seen are a little too basic and the one I tried writing is error ridden.
My CMS Approach - Good Or Bad?
I ask all php-freaks say how they feel this CMS approach especially from the point of view of 1) admin usability, 2) user rights management and) database speed. In my approach webcontent could be seen as a content-tree, where most of the content would be in one table called "nodes". Content types would be: - branchwebpages and simple categories(=menuitems that have only subitems, not content) are the branches - leafwebpages (those that don't grow forward), galleryimages and documents(doc, pdf, rtf) are the leaves Would this one nodetable with its huge datafield(s) be too heavy, remembering that other images than imagenodes would be in an other table? In additon top this, there would be a general image bank and user image bank and those images could be easily added to webpages ideally through htmlarea or at least in "normal way" where images are placed automatically somewhere. If this approach could be combined with a clever & natural permission system (and some template thinking), i would see that possibility to replace webpage management, event management, news management, public docs management, intranet management, image gallery and discussion forum with one application, although it should be very safe in this case. But I am ready to drop at least discussion forum and intranet management for security reasons and to avoid developer exhaustion..! Do You get what I mean: - Superadmin can manage users, publish/add/edit/delete ANY nodes everywhere BUT NOT change the type of the node nor the original author of the node. - Editor can do same but not manage users. - Writers can only publish/add/edit/delete their own nodes everywhere - "Drafters" can only add/edit/delete their own nodes everywhere but not publish them. - "Discussers(?)" can only publish/add/edit/delete their own nodes UNDER discussion nodes. - "Photographers" can only publish/add/edit/delete their own nodes UNDER imagegallerynodes. Does this make sense? Are these mentioned roles reasonable? I see some problem with person who is photographer and discusser, but not still enough trusted to be a writer. First tree (superadmin, editor and writer) are working well I guess, but others seem to be "component roles" of "content provider". Let my try look this in bitwise system that many have mentioned: define("SUPERADMIN", 1); define("EDITOR", 2); define("WRITER", 4); define("DRAFTER", 8); define("DISCUSSER", 16); define("PHOTOGRAPHER", 32); But now _relevant_ options would be: 1 superadmin 2 editor 4 writer 8 drafter 16 discusser 32 photographer 24 drafter + discusser 40 drafter + photographer 48 discusser + photographer 56 drafter + discusser+ photographer
Good Way To Pass Login
Hi groupmates, There are two main methods to identify a user login. One is using Cookie to store the user name after login, Another is to use Session to store the user name. Anything else? I think both are facing a risk that some people can fake those cookie or sessionid to access our restriced area. What do you think about providing a better Login System?
A Good Way To Deal With SQL Injection
I was trying to think up a nice, simple solution to SQL injection while pondering my top ten vulnerability list. Here's something I came up with....
Looking For A Good Php Book To Use With Adobe CS3
Sometime back I bought a couple books on Dreamweaver and Flash for the CS2 Suite and along with it bought a book for Php, Foundation Php for Dreamweaver 8. I read the Dreamweaver and Flash books but never have read the Php book. Now that I was ready to I just upgraded to the CS3 suite. My question is, is it important to look for a newer Php book to use with this CS3 suite or would the current book be ok and up to date? Should I look into the Foundation Php 5 for Flash 8 as a complement to the current book or is there a completely other book I should look into? I'm completely new at Php so am definitely looking at something that's entry level.
|