![]() |
Stupid PHP Code Question...
Im getting this error on an old php file im trying to migrate across to a new server...
http://www.pixelsquaredesigns.com/words/ Any of the programmer types on here know whats causing it? Here is the code... Code:
<?php |
Fatal error: Call to undefined function strip_newlines() in /home/orange/public_html/pixelsquaredesigns.com/words/index.php on line 19
I'm going to guess that the strip_newlines function isn't defined :) Your code says " // strip_newlines is not a real function - needs to be implemented " so I'm guessing the function wasn't added. |
as CYF says
looks like your old server had display errors turned off in php.ini (which you should have for a production server) so you were not seeing this error. |
So how would i fix it? I know it used to work on the old server with no problems :(
|
So ive edited some of the code (new code is in red) but its now throwing out a different error :(
http://www.pixelsquaredesigns.com/words/ Code:
<?php Sorry I'm definitely not fluent in .php but I'm learning slowly... Or trying to lol |
Code:
<?php |
Ask KILLSWITCH or the so Fucking Banned "EDGEPROD", HO HO HO.
They claim theirselves to be PHP NINJAS... lol.. they dont have a fucking clue about coding at all.. Fucking noobs. |
|
That new error, "Parse error: syntax error, unexpected $end", means you are missing a closing bracket. A right curly bracket, } needs to match up with one of the opening ones, {.
Another problem with your new code is although you have now defined a strip_newlines function, it is never actually called, plus it is being defined in a loop for no reason. Those were the problems, cemtex's code should get you on track. |
Quote:
Like i said, I'm learning php slowly, i knew there was an issue just couldnt 'see' what it was in my head. So i was basically screwing up the handling of strip_newlines forcing the array in there, correct? |
Layer 7 firewall
|
Quote:
|
Quote:
|
HAHA, funny that KILLSWITCH thinks I was referring to GFY...
Im laughing my ass off... DOMINICO is definitely banned from that place, I had one of my friends member of the forum check on it. :) Same as I have him gathering all the posts I cannot read, every single day... So I stay up to date and I know exactly what you post and that someone opened a thread... Don't worry, Im always watching. :) Take it with Lube. |
Quote:
|
Cada vez que busco tu nombre en google, me rio a carcajadas...
Reputation destroyed. :) y el proximo afectado sera edgeprod, el sicko de conectivut... hihihi... yup, saw him banned yesterday on that other place.. dont worry, I dont follow ur game. |
Quote:
|
Quote:
|
You know, something just occurred to me: if he WAS having access to that forum, he'd see me posting on it every day, so ... I guess he got caught in a lie either way. Ah well, it's not like he had credibility. GFY sure is nice without seeing his posts, using your ignore tool .. but if you keep QUOTING him, we still have to see THAT stuff, lol.
|
Quote:
|
Quote:
Also: I HAVE REPORTED YOU TO THE FBI TEAM, THE GOOGLES, GIT-HUBBLE, AND FACE-BOOKING (where you have only 6 likes, how can you call yourself a WEBMATADOR)? |
Quote:
|
Quote:
|
Quote:
|
So this is doing what it is supposed to now but i had one more question, and im not sure if its possible or not from what ive been reading, i can replace the string for a blank space however, i also read it only works for white space at the beginning or end of a word.
Is there any way i can have this script output a list like this.... onetwo onethree twoone twothree Instead of like this how it currently does... one two one three two one two three If so, what would i put in the code and where would i put it? Thanks for all the assistance so far :) |
Quote:
|
Quote:
|
Ah, it was the $var I was missing... Thank you kindly Sir :)
|
Im still screwing something up :(
http://www.pixelsquaredesigns.com/words/ Has a bunch of spaces between the words, except for the last 4 lines now :/ |
Quote:
So, instead of just doing the replace do a trim when you put the words together. Here: array_push($cwords, $curword . $word); Change to array_push($cwords, trim($curword) . trim($word)); or Here: array_push($words, strip_newlines(fgets($handle))); change to array_push($words, trim(strip_newlines(fgets($handle)))); Trim takes white space (not just blanks) from the beginning and end of the string. Edited in: A better place for it is in the strip_newlines function actually. Changing return $str; to return trim($str); will accomplish the exact same thing with slightly less typing. It depends on how you would interpret what you want the strip_newlines function to be as to whether it is in the right place. |
Looking at it, I don't like the strip_newlines function in there either...lol.
I always use chr(13) and chr(10) for my new line indicators and it never fails. So, on the read (the fget) you can do a replace of all of it and get rid of the function. changing the read to: array_push($words, str_replace(chr(13),'',str_replace(chr(10), '', fgets($handle)))); and getting rid of the function should take care of it nicely. If you also want rid of spaces and such (just in case) then: array_push($words, trim(str_replace(chr(13),'',str_replace(chr(10), '', fgets($handle))))); Should take care of it. |
Quote:
Stupid question though, if this was just a list of words typed in notepad, one word per line, how come there was a space in there, is that an issue with the server parsing the array or something notepad related? |
Quote:
Your strip_newlines function is NOT stripping properly. I just did a couple of tests just to prove it to myself. There was still a carriage return and linefeed in there. Too loopy right now to look through the function. I say get rid of it because it is unneeded. If you go back to the code before the trim and look at view source you will see that what in html looked like a space was actual a skip down a line. But since html does not use carriage returns (it uses the <br> tag) you do not see it in the browser. Handling the carriage return/line feeds using the chr (character function) takes care of it. |
Ok, the issue in the strip_newlines.
The function as shown above is using single ticks (apostrophes) for the variables: newlines = array(0 => '\r', 1 => '\n', 2 => '\r\n'); Those need to be in double tics (quotes): newlines = array(0 => "\r", 1 => "\n", 2 => "\r\n"); Then, it will work. But there is a condition that will NEVER get hit. The third "\r\n" will never be encountered so it can be left out and you could use newlines = array(0 => "\r", 1 => "\n"); That would work properly and give the proper result. . |
Okay cool ill have a play with this again in the morning then, time to get mah drink on right now, thank you again for the help :)
|
Quote:
I didn't know you were a homo. And something tells me that IF I keep searching, I can also find KILLSWITCH profil too... Right JOSHUA TREE ? :action-sm KARMA is a bitch! |
:1orglaugh
|
Well, signing us up for gay dating profiles is hil-fucking-arious and all, but it's nice to see him banned, too.
|
Damn, I've been out all day helping my buddy buy an engagement ring... What did I miss? What caused him to be banned?
|
All times are GMT -7. The time now is 05:32 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc