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.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 12-13-2012, 11:41 PM   #1
Webmaster Advertising
So Fucking Banned
 
Join Date: Sep 2003
Posts: 1,360
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

// 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>";

?>
Thanks in advance for any assistance you can offer
Webmaster Advertising is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-13-2012, 11:51 PM   #2
CYF
Coupon Guru
 
CYF's Avatar
 
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


Last edited by CYF; 12-13-2012 at 11:52 PM..
CYF is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 12:38 AM   #3
borked
Totally Borked
 
borked's Avatar
 
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
borked is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 12:41 AM   #4
Webmaster Advertising
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
Webmaster Advertising is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 01:04 AM   #5
Webmaster Advertising
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>";

?>
What did I screw up? LOL

Sorry I'm definitely not fluent in .php but I'm learning slowly... Or trying to lol
Webmaster Advertising is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 02:54 AM   #6
cemtex
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>";

?>
__________________
cemtex is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 03:14 AM   #7
VenusBlogger
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.
VenusBlogger is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 04:19 AM   #8
Emil
Confirmed User
 
Emil's Avatar
 
Join Date: Feb 2007
Location: Sweden
Posts: 5,623
http://fiverr.com/gigs/search?query=fix+php&x=0&y=0
__________________
Free 🅑🅘🅣🅒🅞🅘🅝🅢 Every Hour (Yes, really. Free ₿itCoins.)
(Signup with ONLY your Email and Password. You can also refer people and get even more.)
Emil is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 05:38 AM   #9
amphora
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.
amphora is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 09:34 AM   #10
Webmaster Advertising
So Fucking Banned
 
Join Date: Sep 2003
Posts: 1,360
Quote:
Originally Posted by cemtex View Post
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>";

?>
Thank you kindly, its appreciated.

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?
Webmaster Advertising is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 09:36 AM   #11
Vapid - BANNED FOR LIFE
Barterer
 
Industry Role:
Join Date: Aug 2004
Posts: 4,864
Layer 7 firewall
Vapid - BANNED FOR LIFE is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 09:48 AM   #12
Webmaster Advertising
So Fucking Banned
 
Join Date: Sep 2003
Posts: 1,360
Quote:
Originally Posted by amphora View Post
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.
Thank you for the explanation
Webmaster Advertising is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 10:26 AM   #13
Killswitch
👏 REVOLUTIONARY 👏
 
Killswitch's Avatar
 
Industry Role:
Join Date: Oct 2012
Posts: 2,304
Quote:
Originally Posted by VenusBlogger View Post
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.
__________________
Killswitch is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 05:22 PM   #14
VenusBlogger
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.

Last edited by VenusBlogger; 12-14-2012 at 05:24 PM..
VenusBlogger is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 05:35 PM   #15
Killswitch
👏 REVOLUTIONARY 👏
 
Killswitch's Avatar
 
Industry Role:
Join Date: Oct 2012
Posts: 2,304
Quote:
Originally Posted by VenusBlogger View Post
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.
Your rat is filling you with bullshit.
__________________
Killswitch is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 05:47 PM   #16
VenusBlogger
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.

Last edited by VenusBlogger; 12-14-2012 at 05:49 PM..
VenusBlogger is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 05:59 PM   #17
edgeprod
Permanently Gone
 
Industry Role:
Join Date: Mar 2004
Posts: 10,019
Quote:
Originally Posted by Killswitch View Post
Your rat is filling you with bullshit.
I'm laughing my balls off, because whoever is feeding him bad info, he probably thinks they're friends ... and the whole time .. oh, god I have tears in my eyes, I'm laughing so hard. Totally worth it.
edgeprod is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 06:07 PM   #18
Killswitch
👏 REVOLUTIONARY 👏
 
Killswitch's Avatar
 
Industry Role:
Join Date: Oct 2012
Posts: 2,304
Quote:
Originally Posted by edgeprod View Post
I'm laughing my balls off, because whoever is feeding him bad info, he probably thinks they're friends ... and the whole time .. oh, god I have tears in my eyes, I'm laughing so hard. Totally worth it.
__________________
Killswitch is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 07:26 PM   #19
edgeprod
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.
edgeprod is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 07:41 PM   #20
Killswitch
👏 REVOLUTIONARY 👏
 
Killswitch's Avatar
 
Industry Role:
Join Date: Oct 2012
Posts: 2,304
Quote:
Originally Posted by edgeprod View Post
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.
My good your bad. How's it working on your fourth computer since it RUINED your first THREE computers?
__________________
Killswitch is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 07:58 PM   #21
edgeprod
Permanently Gone
 
Industry Role:
Join Date: Mar 2004
Posts: 10,019
Quote:
Originally Posted by Killswitch View Post
My good your bad. How's it working on your fourth computer since it RUINED your first THREE computers?
My first 43 computers. I just kept trying, and your damn script just kept RUINING computers. I had to actually throw them all out afterward. If I weren't in a third world country running a 486 DX, I'd ask you to replace at least one of them with a smoke signal station or a messenger pigeon, KILL-SWITCH.

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)?
edgeprod is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 08:19 PM   #22
Killswitch
👏 REVOLUTIONARY 👏
 
Killswitch's Avatar
 
Industry Role:
Join Date: Oct 2012
Posts: 2,304
Quote:
Originally Posted by edgeprod View Post
My first 43 computers. I just kept trying, and your damn script just kept RUINING computers. I had to actually throw them all out afterward. If I weren't in a third world country running a 486 DX, I'd ask you to replace at least one of them with a smoke signal station or a messenger pigeon, KILL-SWITCH.

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)?
Just for this post I have banned you from GFY. Enjoy your SO FUCKING BANNED status, EDGE-PROD!
__________________
Killswitch is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 08:31 PM   #23
edgeprod
Permanently Gone
 
Industry Role:
Join Date: Mar 2004
Posts: 10,019
Quote:
Originally Posted by Killswitch View Post
Just for this post I have banned you from GFY. Enjoy your SO FUCKING BANNED status, EDGE-PROD!
You FATTY, I will call you a KICK-BOXER now.
edgeprod is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 08:49 PM   #24
Killswitch
👏 REVOLUTIONARY 👏
 
Killswitch's Avatar
 
Industry Role:
Join Date: Oct 2012
Posts: 2,304
Quote:
Originally Posted by edgeprod View Post
You FATTY, I will call you a KICK-BOXER now.
You can't respond to this because you're SO FUCKING BANNED!
__________________
Killswitch is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 09:25 PM   #25
Webmaster Advertising
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
Webmaster Advertising is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 09:26 PM   #26
edgeprod
Permanently Gone
 
Industry Role:
Join Date: Mar 2004
Posts: 10,019
Quote:
Originally Posted by Killswitch View Post
You can't respond to this because you're SO FUCKING BANNED!
I forgot.
edgeprod is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 09:40 PM   #27
Killswitch
👏 REVOLUTIONARY 👏
 
Killswitch's Avatar
 
Industry Role:
Join Date: Oct 2012
Posts: 2,304
Quote:
Originally Posted by Webmaster Advertising View Post
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
str_replace(' ', '', $var);
__________________
Killswitch is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 09:45 PM   #28
Webmaster Advertising
So Fucking Banned
 
Join Date: Sep 2003
Posts: 1,360
Ah, it was the $var I was missing... Thank you kindly Sir
Webmaster Advertising is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 10:03 PM   #29
Webmaster Advertising
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 :/
Webmaster Advertising is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 10:22 PM   #30
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
Quote:
Originally Posted by Webmaster Advertising View Post
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 :/
You have something other than a space in there.

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!

Last edited by sarettah; 12-14-2012 at 10:28 PM..
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 10:37 PM   #31
sarettah
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!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 10:42 PM   #32
Webmaster Advertising
So Fucking Banned
 
Join Date: Sep 2003
Posts: 1,360
Quote:
Originally Posted by sarettah View Post
You have something other than a space in there.

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.
Trim worked perfectly, thanks Sarettah.

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?
Webmaster Advertising is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 10:49 PM   #33
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
Quote:
Originally Posted by Webmaster Advertising View Post
Trim worked perfectly, thanks Sarettah.

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?
There was no space.

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!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 11:06 PM   #34
sarettah
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!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-14-2012, 11:13 PM   #35
Webmaster Advertising
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
Webmaster Advertising is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-15-2012, 03:20 AM   #36
VenusBlogger
So Fucking Banned
 
Industry Role:
Join Date: Nov 2011
Posts: 1,540
Quote:
Originally Posted by edgeprod View Post
I forgot.
EDGE-PROOF why is your profile in GAY DATING Sites along with your wikipidia pic ?

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 ?

KARMA is a bitch!
VenusBlogger is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-15-2012, 09:07 AM   #37
Killswitch
👏 REVOLUTIONARY 👏
 
Killswitch's Avatar
 
Industry Role:
Join Date: Oct 2012
Posts: 2,304
__________________
Killswitch is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-15-2012, 11:28 AM   #38
edgeprod
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.
edgeprod is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 12-15-2012, 09:54 PM   #39
Killswitch
👏 REVOLUTIONARY 👏
 
Killswitch's Avatar
 
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?
__________________
Killswitch is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.