![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
So Fucking Banned
Join Date: Sep 2003
Posts: 1,360
|
![]() 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 // Text file containing words $txt = '/home/orange/public_html/pixelsquaredesigns.com/words/list.txt'; $handle = fopen($txt, 'r'); if (!$handle) { die('Could not open...'); } // set up arrays for storing words and concatenated words $words = array(); $cwords = array(); // get the words while (!feof($handle)) { // strip_newlines is not a real function - needs to be implemented array_push($words, strip_newlines(fgets($handle))); } // while we still have words for ($i = 0; $i < count($words); $i++) { // get the current word $curword = $words[$i]; // loop over the words foreach ($words as $word) { // if the word is the same as the current word, skip it - i.e. no CatCat if ($word == $curword) { continue; } // append the concatenated word to the array array_push($cwords, $curword.$word); } } foreach ($words as $var) echo $var."<br>"; foreach ($cwords as $var2) echo $var2."<br>"; ?> ![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Coupon Guru
Industry Role:
Join Date: Mar 2009
Location: Minneapolis
Posts: 10,973
|
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.
__________________
Webmaster Coupons Coupons and discounts for hosting, domains, SSL Certs, and more! AmeriNOC Coupons | Certified Hosting Coupons | Hosting Coupons | Domain Name Coupons ![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Totally Borked
Industry Role:
Join Date: Feb 2005
Posts: 6,284
|
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.
__________________
![]() For coding work - hit me up on andy // borkedcoder // com (consider figuring out the email as test #1) All models are wrong, but some are useful. George E.P. Box. p202 |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
So Fucking Banned
Join Date: Sep 2003
Posts: 1,360
|
So how would i fix it? I know it used to work on the old server with no problems
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
So Fucking Banned
Join Date: Sep 2003
Posts: 1,360
|
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 // Text file containing words $txt = '/home/orange/public_html/pixelsquaredesigns.com/words/list.txt'; $handle = fopen($txt, 'r'); if (!$handle) { die('Could not open...'); } // set up arrays for storing words and concatenated words $words = array(); $cwords = array(); // get the words while (!feof($handle)) { function strip_newlines($str) { // common newline sequences - \r (carriage return), \n (newline or linefeed), and \r\n (carriage return-linefeed) $newlines = array(0 => '\r', 1 => '\n', 2 => '\r\n'); // loop over the newline sequences, replacing them with nothing in the string foreach ($newlines as $nl) { $str = str_replace($nl, '', $str); } // return the cleaned string return $str; } // while we still have words for ($i = 0; $i < count($words); $i++) { // get the current word $curword = $words[$i]; // loop over the words foreach ($words as $word) { // if the word is the same as the current word, skip it - i.e. no CatCat if ($word == $curword) { continue; } // append the concatenated word to the array array_push($cwords, $curword.$word); } } foreach ($words as $var) echo $var."<br>"; foreach ($cwords as $var2) echo $var2."<br>"; ?> Sorry I'm definitely not fluent in .php but I'm learning slowly... Or trying to lol |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
Confirmed User
Join Date: Nov 2006
Posts: 289
|
Code:
<?php // Text file containing words $txt = 'list.txt'; // function function strip_newlines($str) { // common newline sequences - \r (carriage return), \n (newline or linefeed), and \r\n (carriage return-linefeed) $newlines = array(0 => '\r', 1 => '\n', 2 => '\r\n'); // loop over the newline sequences, replacing them with nothing in the string foreach ($newlines as $nl) { $str = str_replace($nl, '', $str); } // return the cleaned string return $str; } $handle = fopen($txt, 'r'); if (!$handle) { die('Could not open...'); } // set up arrays for storing words and concatenated words $words = array(); $cwords = array(); // get the words while (!feof($handle)) { // strip_newlines is not a real function - needs to be implemented array_push($words, strip_newlines(fgets($handle))); } // while we still have words for ($i = 0; $i < count($words); $i++) { // get the current word $curword = $words[$i]; // loop over the words foreach ($words as $word) { // if the word is the same as the current word, skip it - i.e. no CatCat if ($word == $curword) { continue; } // append the concatenated word to the array array_push($cwords, $curword.$word); } } foreach ($words as $var) echo $var."<br>"; foreach ($cwords as $var2) echo $var2."<br>"; ?> |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
So Fucking Banned
Industry Role:
Join Date: Nov 2011
Posts: 1,540
|
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. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
Confirmed User
Join Date: Feb 2007
Location: Sweden
Posts: 5,623
|
__________________
Free 🅑🅘🅣🅒🅞🅘🅝🅢 Every Hour (Yes, really. Free ₿itCoins.) (Signup with ONLY your Email and Password. You can also refer people and get even more.) |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 |
Registered User
Industry Role:
Join Date: Nov 2012
Posts: 1
|
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. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#10 | |
So Fucking Banned
Join Date: Sep 2003
Posts: 1,360
|
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? |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#11 |
Barterer
Industry Role:
Join Date: Aug 2004
Posts: 4,864
|
Layer 7 firewall
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#12 | |
So Fucking Banned
Join Date: Sep 2003
Posts: 1,360
|
Quote:
![]() |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#13 | |
👏 REVOLUTIONARY 👏
Industry Role:
Join Date: Oct 2012
Posts: 2,304
|
Quote:
![]()
__________________
![]() |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#14 |
So Fucking Banned
Industry Role:
Join Date: Nov 2011
Posts: 1,540
|
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. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#15 | |
👏 REVOLUTIONARY 👏
Industry Role:
Join Date: Oct 2012
Posts: 2,304
|
Quote:
__________________
![]() |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#16 |
So Fucking Banned
Industry Role:
Join Date: Nov 2011
Posts: 1,540
|
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. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#17 |
Permanently Gone
Industry Role:
Join Date: Mar 2004
Posts: 10,019
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#18 | |
👏 REVOLUTIONARY 👏
Industry Role:
Join Date: Oct 2012
Posts: 2,304
|
Quote:
![]() ![]() ![]()
__________________
![]() |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#19 |
Permanently Gone
Industry Role:
Join Date: Mar 2004
Posts: 10,019
|
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.
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#20 | |
👏 REVOLUTIONARY 👏
Industry Role:
Join Date: Oct 2012
Posts: 2,304
|
Quote:
![]()
__________________
![]() |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#21 | |
Permanently Gone
Industry Role:
Join Date: Mar 2004
Posts: 10,019
|
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)? |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#22 | |
👏 REVOLUTIONARY 👏
Industry Role:
Join Date: Oct 2012
Posts: 2,304
|
Quote:
![]()
__________________
![]() |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#23 |
Permanently Gone
Industry Role:
Join Date: Mar 2004
Posts: 10,019
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#24 |
👏 REVOLUTIONARY 👏
Industry Role:
Join Date: Oct 2012
Posts: 2,304
|
You can't respond to this because you're SO FUCKING BANNED!
![]()
__________________
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#25 |
So Fucking Banned
Join Date: Sep 2003
Posts: 1,360
|
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 ![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#26 |
Permanently Gone
Industry Role:
Join Date: Mar 2004
Posts: 10,019
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#27 | |
👏 REVOLUTIONARY 👏
Industry Role:
Join Date: Oct 2012
Posts: 2,304
|
Quote:
__________________
![]() |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#28 |
So Fucking Banned
Join Date: Sep 2003
Posts: 1,360
|
Ah, it was the $var I was missing... Thank you kindly Sir
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#29 |
So Fucking Banned
Join Date: Sep 2003
Posts: 1,360
|
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 :/ |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#30 | |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,053
|
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.
__________________
All cookies cleared! |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#31 |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,053
|
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.
__________________
All cookies cleared! |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#32 | |
So Fucking Banned
Join Date: Sep 2003
Posts: 1,360
|
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? |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#33 | |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,053
|
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.
__________________
All cookies cleared! |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#34 |
see you later, I'm gone
Industry Role:
Join Date: Oct 2002
Posts: 14,053
|
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. .
__________________
All cookies cleared! |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#35 |
So Fucking Banned
Join Date: Sep 2003
Posts: 1,360
|
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
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#36 |
So Fucking Banned
Industry Role:
Join Date: Nov 2011
Posts: 1,540
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#37 |
👏 REVOLUTIONARY 👏
Industry Role:
Join Date: Oct 2012
Posts: 2,304
|
![]()
__________________
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#38 |
Permanently Gone
Industry Role:
Join Date: Mar 2004
Posts: 10,019
|
Well, signing us up for gay dating profiles is hil-fucking-arious and all, but it's nice to see him banned, too.
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#39 |
👏 REVOLUTIONARY 👏
Industry Role:
Join Date: Oct 2012
Posts: 2,304
|
Damn, I've been out all day helping my buddy buy an engagement ring... What did I miss? What caused him to be banned?
__________________
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |